fork(2) 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.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15.  
  16. Instant instant = Instant.ofEpochSecond( 1_379_487_711L ) ;
  17. ZoneId z = ZoneId.of( "America/Montreal" ) ;
  18. ZonedDateTime zdt = instant.atZone( z ) ;
  19.  
  20. DateTimeFormatter f = DateTimeFormatter.ofPattern( "dd-MM-uuuu" ) ;
  21. String output = zdt.format( f ) ;
  22.  
  23. System.out.println( "instant.toString(): " + instant ) ;
  24. System.out.println( "zdt.toString(): " + zdt ) ;
  25. System.out.println( "output: " + output ) ;
  26.  
  27.  
  28.  
  29.  
  30. }
  31. }
Success #stdin #stdout 0.19s 2184192KB
stdin
Standard input is empty
stdout
instant.toString(): 2013-09-18T07:01:51Z
zdt.toString(): 2013-09-18T03:01:51-04:00[America/Montreal]
output: 18-09-2013