fork 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. /* 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.  
  17. Instant instant = Instant.parse( "2019-11-26T19:30:00Z" ) ; // Default format for parsing a moment in UTC.
  18. ZoneId z = ZoneId.of( "America/Edmonton" ) ; // A time zone is a history of past, present, and future changes to the offset used by the people of a particular region.
  19. ZonedDateTime zdt = instant.atZone( z ) ; // Same moment, same point on the timeline, different wall-clock time.
  20.  
  21. System.out.println( "instant.toString(): " + instant ) ;
  22. System.out.println( "zdt.toString(): " + zdt ) ;
  23. }
  24. }
Success #stdin #stdout 0.13s 38920KB
stdin
Standard input is empty
stdout
instant.toString(): 2019-11-26T19:30:00Z
zdt.toString(): 2019-11-26T12:30-07:00[America/Edmonton]