P E N C I L
Login
Java8+ and time
  1. https://www.javabrahman.com/java-8/working-with-time-zones-in-java-8-zoneddatetime-zoneid-tutorial-with-examples/
  2. ZoneId.of(""), ZoneOffset.UTC (instance of ZoneId)
  3. Instant.now(): wrapper of nano from EPOCH
  4. LocalDateTime local = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);
    Convert instant to date+time at timezone UTC. After convert there is no information about the timezone in "local"
  5. ZonedDateTime.ofInstant(instant, ZoneOffset.UTC);
    Convert to ZoneID and the returned object still have info of timezone
  6. ZonedDateTime zonedDateTime = LocalDateTime.parse("2018-02-14T06:30").atZone(ZoneId.of("Europe/Paris"));
  7. ZoneOffset extends ZoneId.
    ZoneId tokyo = ZoneId.of("Asia/Tokyo");
    ZoneId.systemDefault()
  8. String formatted = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss").format(localDateTime);
  9. Instant.now()
    LocalDate.now(), LocalTime.now(), LocalDateTime.now()
    ZonedDateTime.now()
  10. LocalDate.of(2018,2,13)
    LocalDateTime dateTime = LocalDate.parse("2018-02-13").atTime(LocalTime.parse("06:30"));
    ZonedDateTime zonedDateTime = LocalDateTime.parse("2018-02-14T06:30").atZone(ZoneId.of("Europe/Paris"));
  11. SQL: javax.sql.timestamp
  12. Java7 = Java8
    Date.valueOf(LocalDate) => Take date, 0 time,timezone=system timezone.
  13. https://stackoverflow.com/questions/4117249/what-time-zone-does-hibernate-use-when-it-reads-and-writes-a-java-calendar-objec
  14. http://blog.montrosesoftware.com/2016/11/08/dates-and-times-in-java-unexpected-timezone-shift/