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.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14.  
  15. ZonedDateTime edmonton = ZonedDateTime.now( ZoneId.of( "America/Edmonton" ) ) ;
  16. ZonedDateTime tunis = ZonedDateTime.now( ZoneId.of( "Africa/Tunis" ) ) ;
  17.  
  18. LocalTime edmontonTime = edmonton.toLocalTime() ;
  19. LocalTime tunisTime = tunis.toLocalTime() ;
  20.  
  21. boolean isEdmontonEarlierTimeThanTunis = edmontonTime.isBefore( tunisTime ) ;
  22.  
  23. System.out.println( edmonton ) ;
  24. System.out.println( tunis ) ;
  25. System.out.println( "isEdmontonEarlierTimeThanTunis: " + isEdmontonEarlierTimeThanTunis + " edmontonTime: " + edmontonTime + " tunisTime: " + tunisTime ) ;
  26.  
  27. }
  28. }
Success #stdin #stdout 0.16s 55060KB
stdin
Standard input is empty
stdout
2021-09-01T15:13:55.380552-06:00[America/Edmonton]
2021-09-01T22:13:55.384061+01:00[Africa/Tunis]
isEdmontonEarlierTimeThanTunis: true  edmontonTime: 15:13:55.380552 tunisTime: 22:13:55.384061