OffsetDateTime consists of DateTime and the offset from the UTC, for instance
Offset DateTime: 2021-06-23T11:27:41.622253200+02:00
It includes the current local date and time, 9-digit nanosecond, and then followed by a time zone
Java 8 has introduced java.time.packages and the JDBC 4.2 API added support for the additional SQL types
TIMESTAMP WITH TIME ZONE and TIME WITH TIME ZONE.
@Column(name = "offset_time", columnDefinition = "TIME WITH TIME ZONE")
private OffsetTime offsetTime;
@Column(name = "offset_date_time", columnDefinition = "TIMESTAMP WITH TIME ZONE")
private OffsetDateTime offsetDateTime;
Before Java 8 and JPA 2.2, developers usually had to convert date/time types to UTC before persisting them. JPA 2.2 now supports this feature out of the box by supporting the offset to UTC and by leveraging JDBC 4.2 support for the timezone.
JPA @Column attribute column definition (Optional) The SQL fragment that is used when generating the DDL for the column.
No comments:
Post a Comment