fork(5) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.time.*;
  8. import java.time.format.*;
  9. import java.time.temporal.*;
  10.  
  11.  
  12. /* Name of the class has to be "Main" only if the class is public. */
  13. class Ideone
  14. {
  15. public static void main (String[] args) throws java.lang.Exception
  16. {
  17.  
  18. String input = "Mon Jun 18 00:00:00 IST 2012";
  19. DateTimeFormatter f = DateTimeFormatter.ofPattern( "E MMM dd HH:mm:ss z uuuu" ).withLocale( Locale.US );
  20.  
  21. ZonedDateTime zdt = ZonedDateTime.parse( input , f );
  22.  
  23. LocalDate ld = zdt.toLocalDate();
  24. DateTimeFormatter fLocalDate = DateTimeFormatter.ofPattern( "dd/MM/uuuu" );
  25. String output = ld.format( fLocalDate) ;
  26.  
  27. System.out.println( "input: " + input );
  28. System.out.println( "zdt: " + zdt );
  29. System.out.println( "ld: " + ld );
  30. System.out.println( "output: " + output );
  31.  
  32. }
  33. }
Success #stdin #stdout 0.14s 712192KB
stdin
Standard input is empty
stdout
input: Mon Jun 18 00:00:00 IST 2012
zdt: 2012-06-18T00:00+03:00[Asia/Jerusalem]
ld: 2012-06-18
output: 18/06/2012