fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.time.* ;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. Instant created = Instant.ofEpochMilli( 1_636_334_664_000L ) ;
  14. Instant modified = Instant.ofEpochMilli( 1_636_334_664_001L ) ;
  15. Duration duration = Duration.between( created , modified ) ;
  16.  
  17. System.out.println( created ) ;
  18. System.out.println( modified ) ;
  19. System.out.println( duration ) ;
  20.  
  21. ZoneId z = ZoneId.of( "Asia/Tokyo" ) ;
  22. ZonedDateTime zdtModifiedTokyo = modified.atZone( z ) ;
  23.  
  24. System.out.println( "zdtModifiedTokyo.toString(): " + zdtModifiedTokyo ) ;
  25.  
  26. System.out.println(
  27. Instant.ofEpochMilli( 1_636_334_664_001L ).toString()
  28. );
  29. }
  30. }
Success #stdin #stdout 0.17s 53880KB
stdin
Standard input is empty
stdout
2021-11-08T01:24:24Z
2021-11-08T01:24:24.001Z
PT0.001S
zdtModifiedTokyo.toString(): 2021-11-08T10:24:24.001+09:00[Asia/Tokyo]
2021-11-08T01:24:24.001Z