fork download
  1. import java.time.*;
  2.  
  3. class Example
  4. {
  5. private static long SIXTY_SECONDS_IN_MS = 60000L;
  6.  
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. long l = System.currentTimeMillis();
  10. l = l - (l % SIXTY_SECONDS_IN_MS);
  11. System.out.println("l = " + l);
  12.  
  13. // Checking the result
  14. LocalDateTime dt = Instant.ofEpochMilli(l).atZone(ZoneId.systemDefault()).toLocalDateTime();
  15. System.out.println(dt);
  16. System.out.println(dt.getSecond()); // 0
  17. System.out.println(dt.getNano()); // 0
  18. }
  19. }
Success #stdin #stdout 0.12s 28900KB
stdin
Standard input is empty
stdout
l = 1517938020000
2018-02-06T17:27
0
0