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. long seconds = ( Long.MAX_VALUE / 1_000_000_000L ) ;
  16. long fraction = ( Long.MAX_VALUE % 1_000_000_000L ) ;
  17. long total = ( ( seconds * 1_000_000_000L ) + fraction ) ;
  18. Instant instant = Instant.ofEpochSecond( seconds , fraction ) ;
  19.  
  20. System.out.println( "Long.MAX_VALUE: " + Long.MAX_VALUE ) ;
  21. System.out.println( "seconds: " + seconds ) ;
  22. System.out.println( "fraction: " + fraction ) ;
  23. System.out.println( "total: " + total ) ;
  24. System.out.println( "instant: " + instant ) ;
  25. }
  26. }
Success #stdin #stdout 0.22s 34408KB
stdin
Standard input is empty
stdout
Long.MAX_VALUE: 9223372036854775807
seconds: 9223372036
fraction: 854775807
total: 9223372036854775807
instant: 2262-04-11T23:47:16.854775807Z