| 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 :
@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 :
<property name="hibernate.jdbc.time_zone" value="UTC"/>
Add a new row with a local Time at 12:00pm
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/hiberntae_utc_localTime Just launch the storeLocalTimeShouldReturnWithAnUtcValue() unit test. Hope it can help this option because it's very usefull. It's my first report, if you need more informations please tell me . |