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. LocalDateTime session = LocalDateTime.of(2017, Month.FEBRUARY, 12, 10, 30);
  14. ZonedDateTime zdt = session.atZone(ZoneId.systemDefault());
  15. long millis = zdt.toInstant().toEpochMilli();
  16.  
  17.  
  18. LocalDateTime date =
  19. LocalDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneId.systemDefault());
  20.  
  21. System.out.println("millis " + millis );
  22. System.out.println("date " + date);
  23. }
  24. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
millis 1486895400000
date 2017-02-12T10:30