fork(1) 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. import java.time.chrono.* ;
  11.  
  12.  
  13. /* Name of the class has to be "Main" only if the class is public. */
  14. class Ideone
  15. {
  16. public static void main (String[] args) throws java.lang.Exception
  17. {
  18. String input = "2019-11-14T00:55:31.820Z" ;
  19. Instant instant = Instant.parse( input ) ;
  20.  
  21. ZoneId zMontreal = ZoneId.of( "America/Montreal" ) ;
  22. ZonedDateTime zdtMontreal = instant.atZone( zMontreal ) ;
  23.  
  24. ZoneId zTunis = ZoneId.of( "Africa/Tunis" ) ;
  25. ZonedDateTime zdtTunis = instant.atZone( zTunis ) ;
  26.  
  27. System.out.println( "instant.toString(): " + instant ) ;
  28. System.out.println( "zdtMontreal.toString(): " + zdtMontreal ) ;
  29. System.out.println( "zdtTunis.toString(): " + zdtTunis ) ;
  30. }
  31. }
Success #stdin #stdout 0.15s 38912KB
stdin
Standard input is empty
stdout
instant.toString(): 2019-11-14T00:55:31.820Z
zdtMontreal.toString(): 2019-11-13T19:55:31.820-05:00[America/Montreal]
zdtTunis.toString(): 2019-11-14T01:55:31.820+01:00[Africa/Tunis]