I am using Hibernate and JPA to store my data in a database.
Now I would like to save a ZonedDateTime
from java.time
.
The problem is, Hibernate does only ever persist the date and time. It does not care about the ZoneId
or the offset.
Is there any way to persuade Hibernate to persist that information?
hibernate 5 support java8 datetime types by adding hibernate-java8 dependancy but in version 5.2.10 this moved to hibernate core
(deprecated - use hibernate-core instead) Support for Java8-specific features - mainly Java8 Date/Time (JSR 310)
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-java8 -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-java8</artifactId>
</dependency>
for more information about hibernate and datetime see this
import java.time.Instant;
@Column(name = "reset_date")
private Instant resetDate = null;
setResetDate(Instant.now());
https://www.thoughts-on-java.org/hibernate-5-date-and-time/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With