<i18n dev> TimeZone API for getting raw offset and daylight saving amount

Yoshito Umaoka y.umaoka at gmail.com
Wed Aug 13 12:14:42 PDT 2008


Oops.. stupid mistake in the previous note..

 > public void getOffset(long date, int[] offsets) {
 >     if (offsets == null || offsets.length < 2) {
 >         offsets = new int[2];
 >     }
 >     if (inDaylightTime(new Date(date)) {
 >         offsets[1] = getDSTSavings();
 >         offsets[0] = getOffset(date) - offsets[1];
 >     } else {
 >         offsets[0] = getOffset(date);
 >         offsets[1] = 0;
 >     }
 > }

int[] is not a return value of the method..
Just let it throw NullPointerException or
ArrayIndexOutOfBoundsException when int[] offsets is null
or too short.

public void getOffset(long date, int[] offsets) {
     if (inDaylightTime(new Date(date)) {
         offsets[1] = getDSTSavings();
         offsets[0] = getOffset(date) - offsets[1];
     } else {
         offsets[0] = getOffset(date);
         offsets[1] = 0;
     }
}

Yoshito Umaoka (ICU Project)



More information about the i18n-dev mailing list