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. Clock clock1 = Clock.system(ZoneId.of("Europe/Paris"));
  15. Clock clock2 = Clock.system(ZoneId.of("Asia/Kolkata"));
  16.  
  17. System.out.println("Clock1 instant: " + clock1.instant());
  18. System.out.println("Clock2 instant: " + clock2.instant());
  19.  
  20. System.out.println( "ZoneId.systemDefault(): " + ZoneId.systemDefault() ) ;
  21.  
  22. System.out.println("Clock1 ZonedDateTime.now: " + ZonedDateTime.now( clock1 ) );
  23. System.out.println("Clock2 ZonedDateTime.now: " + ZonedDateTime.now( clock2 ) );
  24.  
  25. System.out.println( "ZoneId.systemDefault(): " + ZoneId.systemDefault() ) ;
  26. }
  27. }
Success #stdin #stdout 0.17s 62648KB
stdin
Standard input is empty
stdout
Clock1 instant: 2024-11-19T13:38:09.024308Z
Clock2 instant: 2024-11-19T13:38:09.065290Z
ZoneId.systemDefault(): GMT
Clock1 ZonedDateTime.now: 2024-11-19T14:38:09.096512+01:00[Europe/Paris]
Clock2 ZonedDateTime.now: 2024-11-19T19:08:09.099290+05:30[Asia/Kolkata]
ZoneId.systemDefault(): GMT