Wednesday, August 1, 2012

JPA/Hibernate store date in UTC time zone

To the best of my knowledge, you need to put your entire java app in UTC timezone (so that hibernate will store dates in UTC), and you'll need to convert to whatever timezone desired when you display stuff (at least we do it this way).
At startup, we do:
TimeZone.setDefault(TimeZone.getTimeZone("Etc/UTC"));
and set the desired timezone to the DateFormat:
fmt.setTimeZone(TimeZone.getTimeZone("Europe/Budapest"))
Hope this helps,
cheers,
mitch

http://stackoverflow.com/questions/508019/jpa-hibernate-store-date-in-utc-time-zone

No comments:

Post a Comment