We're updating the issue view to help you get more done. 

DST is ignored when saving a LocalTime with hibernate.jdbc.time_zone=UTC

Description

Hello everybody,
When I want to store LocalTime and OffsetTime into a Time column with the hibernate.jdbc.time_zone set on "UTC" the value is not correctly handle if we are on a Daylight Saving Time period.

Consider this entity :

1 2 3 4 5 6 7 8 9 10 11 12 @Entity @Table(name = "avdev_myData") public class MyData implements Serializable { private static final long serialVersionUID = 1L; @Id private Long id; @Column(name = "local_time") private LocalTime localTime; }

Add this in your configuration :

1 <property name="hibernate.jdbc.time_zone" value="UTC"/>

Add a new row with a local Time at 12:00pm

1 2 3 4 5 6 MyData myData = new MyData(); myData.setId(1L); myData.setLocalTime(LocalTime.of(12, 0)); entityManager.persist(myData); entityManager.getTransaction().commit();

The value expected is: 10:00am
The actual value is: 11:00am

Change with Instant object and Timestamp column make it working as expected and the value stored is "My time minus 2 hours". Because we are on a DST period, the transformation for LocalTime into UTC values are not handle properly and the DST is ignored.

We can reproduced this with both LocalTime and OffsetTime objects.
I have a full test case from Hibernate templates here : https://github.com/avdev4j/hibernate_utc_localTime

Just launch the storeLocalTimeShouldReturnWithAnUtcValue() unit test.

Hope it can help to improve this option because it's very usefull.
If you need more informations please tell me .

Environment

hibernate -> 5.3.6.Final
h2database -> 1.3.176
junit -> 4.12

Status

Assignee

Unassigned

Reporter

Anthony Viard

Fix versions

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.3.6

Priority

Major