For a persistent date or time property, prefer the Java 8 `java.time` API over `java.util.Date`, `java.util.Calendar`, and the `java.sql` date/time classes. JPA 2.2 officially supports these classes, which distinguish dates, times, date-times, and values with a UTC offset. section 6.3.1
Choose a type that matches the value being stored:
- Use `LocalDate` for a SQL `DATE` and `LocalTime` or `OffsetTime` for a SQL `TIME`. section 6.3.1
- Use `Instant`, `LocalDateTime`, `OffsetDateTime`, or `ZonedDateTime` for a SQL `TIMESTAMP`. `Duration` maps to `BIGINT`. section 6.3.1
The older `java.util.Date` mapping has a comparison trap: Hibernate may load it as a JDBC subclass such as `java.sql.Timestamp` to retain database precision. Its `equals()` behavior can then be asymmetric. If nanoseconds do not matter, compare Unix-time milliseconds instead. section 6.3.1
Table 6.3 Date and time types (view table figure)
Compare the Java date/time classes with their ANSI SQL column types. section 6.3.1
