[hibernate-dev] Should the LocalTimeType use the globally configured TimeZone?

Mark Rotteveel mark at lawinegevaar.nl
Fri Oct 5 12:19:51 EDT 2018


On 5-10-2018 15:40, Vlad Mihalcea wrote:
> Hi,
> 
> My question was more about LocalTime, which is much more straightforward to
> address than LocalDateTime in the context of time zones.
> 
> For DateTime types which support timezones, I'll have to study to see what
> other non-breaking alternatives we may have.

The JDBC expectation for use of LocalDate, LocalTime and LocalDateTime 
is that the time/date/datetime is stored **as is** in a DATE, TIME 
(without time zone), or TIMESTAMP (without time zone). So, no mangling 
of time zones.

Supporting the LocalTime/LocalDateTime types for a 'WITH TIMEZONE' type 
(java.sql.Types.TIME_WITH_TIMEZONE and 
java.sql.Types.TIMESTAMP_WITH_TIMEZONE) is not specified in the JDBC 
specification (see table B-4 in JDBC 4.3), it might make sense to map to 
OffsetTime / OffsetDateTime in those cases instead.

That does leaves us in the same place though: which time zone to choose 
for converting a LocalTime/LocalDateTime.

Similarly, a OffsetTime/OffsetDateTime is not specified to be supported 
for a TIME/TIMESTAMP (without timezone), which might necessitate a 
conversion to its LocalXXX equivalent (which, again implies a choice of 
time zone).

Mark
-- 
Mark Rotteveel


More information about the hibernate-dev mailing list