Reputation: 2265
I'm developing a Spring Boot application, a REST API.
Until now I was mapping the entities date-times as LocalDateTime
. But it's required to have the Zone time information, so I guess I should use ZonedDateTime
insteed. But I'm worried about what zone time is actually used. As the data base field has this format: 2004-12-20 18:00:00
so the zone time is calculated based on the current machine (as it's suggested on the documentation).
To avoid any catastrophy, the zone time that should be used is the one that is configured on data base. How I could configure the ZonedDateTimes of my entities to take a specific zone time?
Upvotes: 0
Views: 2357
Reputation: 3176
As described in the link below you have to globally configure hibernate property hibernate.jdbc.time_zone
(in hibernate 5)
https://www.thoughts-on-java.org/hibernate-tips-whats-the-best-way-to-persist-a-zoneddatetime/
Further setting on a specific entity will be ignored as described.
Upvotes: 1