I have noticed we are experiencing inconsistencies with OffsetTime and OffsetDateTime with MySQL serverTimezone set to UTC.
I have demonstrated this by having an entity that has an OffsetTime field and an OffsetDateTime field. For some reason OffsetTime is being converted to having +1 hours to get the UTC time, although the database is set to UTC. OffsetDateTime, which has the same time, except has a date aswell, returns the correct time.
private OffsetTime offsetTime;
private OffsetDateTime offsetDateTime;
Database shows these fields with these values:
When the entity is returned from database, the OffsetTime returned is 10:00:00 (incorrect), however OffsetDateTime is set to "2022-12-22T09:00:00Z" (correct). Example of JSON return below:
What is happening here?
Thanks
Edit: We have no TIMESTAMP column, SELECT @@global.time_zone, @@session.time_zone; in mysql returns +00:00 for both values, another test here. Storing the value in the database using
setOffsetTime(LocalTime.of(9, 0).atOffset(ZoneOffset.UTC));
Printing this before storing using getOffsetTime().toString() returns '09:00Z' however this is stored as 08:00:00.... - one line below I store the datetime using
setOffsetDateTime(LocalDateTime.of(LocalDate.now(), LocalTime.of(9, 0)).atOffset(ZoneOffset.UTC));
and this returns '2022-12-26T09:00Z' despite being stored as '2022-12-26 09:00:00.000000' in the db which is correct.. notice the inconsistency between OffsetTime and OffsetDateTime