0

I am replacing some Jdk 1.6 Calendar usage with Joda ..

I am looking for how to implement/replace the two following methods with Joda

public int getDstOffSet(long millis) {  
    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.setTimeInMillis(millis);
    return calendar.get(Calendar.DST_OFFSET);
}

public int getZoneOffset(long millis) {     
    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.setTimeInMillis(millis);
    return calendar.get(Calendar.ZONE_OFFSET);
}

1 Answers1

1

Joda has a DateTimeZone class with these functions http://www.joda.org/joda-time/apidocs/org/joda/time/DateTimeZone.html

In particular, isStandardOffset will tell you if you're in DST or not, and then you can use getOffset or getStandardOffset.

This question jodatime how to know if daylight savings is on has some examples.

Community
  • 1
  • 1
Jeff Storey
  • 56,312
  • 72
  • 233
  • 406