We're trying to save all dates normalized to UTC in database. Found this link
https://groups.google.com/forum/?fromgroups=#!topic/play-framework/Er46pB5t_OU, but that's not helpful as it suggests changing environment than code.
So, far these are the results for the approaches we tried:
1. play run -Duser.timezone=UTC
This works fine (converts the date to UTC and saves in DB; when retrieving from DB, it keeps the date in UTC). But, we're looking for runtime/programmatic approach.
2. TimeZone.setDefault(TimeZone.getTimeZone("UTC")); in @OnApplicationStart bootstrap job
This converts the date to UTC and saves in DB. But, when fetching, it again does the conversion and date is going back by offset. For example, for UTC+05:30, when saving to DB it minuses 5:30 and when fetching it again reduces 5:30
3. System.setProperty("user.timezone", "UTC"); in @OnApplicationStart bootstrap job. As per docs, this is the programmatic approach for #1.
No conversion is done here.
Can anybody shares some insights here? TIA