开发者

What is the joda-time equivalent of few JDK TimeZone functions

what is the joda-time equivalent of below methods in JDK.

  1. TimeZone.getOffset()
  2. TimeZone.getRawOffset()
  3. TimeZone.inDaylightTime()
  4. TimeZone.useDaylightTime()
  5. TimeZone.getDSTSavings()

My main idea is to store the below in database as suggested by most of the SO posts

  1. time in UTC = joda I开发者_Python百科nstant
  2. time zone offset = which is the equivalent in joda?
  3. dst offset = which is the equivalent in joda?

Also should i store the RawOffset or the DST adjusted offset?


  1. DateTimeZone.getOffset()
  2. DateTimeZone.getStandardOffset()
  3. ! DateTimeZone.isStandardOffset()
  4. ! DateTimeZone.isFixed()
  5. 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:

  1. ReadableInstant.getMillis()
  2. DateTimeZone.getId()

With Java 8, just use ZonedDateTime persisted via DateTimeFormatter.ISO_ZONED_DATE_TIME.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜