Using set up as
I followed spring boot &
I think you should put spring.jpa.properties.hibernate.jdbc.time_zone = UTC
in application.yml
/application.properties
of main/
or test/
, not in db.properties
. And, I think .properties
takes precedence over .yml
. Correct me if I am wrong.
And, this timezone config is also affected by Timezone.getDefault()
.
See this post: https://aboullaite.me/spring-boot-time-zone-configuration-using-hibernate/
And, as I test, I see that if you want to save a java.util.Date
, which has no timezone info in itself(only in its Calendar
property, this is true), and the column definition hold no place for timezone info, this property will affect the value saved to DB, but not that when you retrieve the row from DB; the latter is affected only by Timezone.getDefault()
. Meanwhile, if you set Timezone.getDefault()
, the saved and retrieved value will both be the timezone you want.
So, this property may not be the most proper way to manipulate the value of Date, if you save and query for the information in the same application. Just use Timezone.setDefault(Timezone.getTimezone("XXX"))
.