fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.text.ParseException;
  7. import java.text.SimpleDateFormat;
  8. import java.util.Date;
  9.  
  10.  
  11. /* Name of the class has to be "Main" only if the class is public. */
  12. class Ideone
  13. {
  14. public static void main (String[] args) throws java.lang.Exception
  15. {
  16. String dt = 2 + "-" + 10 + "-" + 2017;
  17. SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
  18. try {
  19. Date dataInterpretada = sdf.parse(dt);
  20.  
  21. System.out.println(""+ sdf.format(dataInterpretada));
  22. } catch (ParseException e) {
  23. e.printStackTrace();
  24. }
  25. }
  26. }
Success #stdin #stdout 0.06s 4386816KB
stdin
Standard input is empty
stdout
02-10-2017