What is the joda-time equivalent of few JDK TimeZone functions
what is the joda-time equivalent of below methods in JDK.
- TimeZone.getOffset()
- TimeZone.getRawOffset()
- TimeZone.inDaylightTime()
- TimeZone.useDaylightTime()
- TimeZone.getDSTSavings()
My main idea is to store the below in database as suggested by most of the SO posts
- time in UTC = joda I开发者_Python百科nstant
- time zone offset = which is the equivalent in joda?
- dst offset = which is the equivalent in joda?
Also should i store the RawOffset or the DST adjusted offset?
- DateTimeZone.getOffset()
- DateTimeZone.getStandardOffset()
- ! DateTimeZone.isStandardOffset()
- ! DateTimeZone.isFixed()
- Not sure.
If you just save the UTC instant and the timezone id (i.e. America/New York and Europe/London, not EST and GMT) then you don't need to worry about storing raw offsets. Especially as offsets change with annoying frequency. Let Joda and the tz database do all the work for you. So store:
- ReadableInstant.getMillis()
- DateTimeZone.getId()
With Java 8, just use ZonedDateTime
persisted via DateTimeFormatter.ISO_ZONED_DATE_TIME
.
精彩评论