-
Bug
-
Resolution: Fixed
-
P3
-
1.1.5
-
1.2beta4
-
generic
-
solaris_2.5
-
Not verified
IHAC who has encountered the following problem during the Daylight Savings
Time switch that was done on Sunday April 5, 1998.
The problem existed on Solaris 2.5.1 and WinNT 4.0 using JDK 1.1.5
Essentially, the problem is that the JDK API TimeZone.getRawOffset did not switch on the Sunday (when it was supposed to) but on Monday.
Test code follows:
1) adjust your time to April 4 1998 then run it. You'll get
Current offset = to Raw offset.
2) adjust your time to April 5 1998 after 3am then run it. You'll get
Current offset = Raw offset - which is incorrect.
3) adjust your time to April 6 1998 then run it. You'll get the
correct offset - 4hrs current vs. 5hrs raw.
-------------- Source Code --------------------
import java.util.Calendar;
import java.util.TimeZone;
import java.util.Date;
public class DaylightSavingsTimeTest {
private Calendar cal;
private TimeZone tz;
public DaylightSavingsTimeTest () {
cal = Calendar.getInstance();
tz = TimeZone.getDefault();
}
public void setCal(Calendar newcal) {
cal = newcal;
}
public void setTz(TimeZone newTz) {
tz = newTz;
}
public void testDst() {
Date dt = cal.getTime();
System.err.println("Date is: "+dt+"\n");
if (tz.inDaylightTime(dt))
System.err.println("We're in Daylight Savings Time.\n");
else
System.err.println("We're not in Daylight Savings Time.\n");
int era = cal.get(Calendar.ERA);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DATE);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
int millis = cal.get(Calendar.MILLISECOND);
long offset = tz.getOffset(era, year, month, day, dayOfWeek, millis);
/*
* Current offset is correct EXCEPT for on 5 April 1998 after 3am
*/
System.err.println("Current offset is " + (offset/1000) / 3600 + " hours.\n");
long raw_offset = tz.getRawOffset();
System.err.println("Raw offset is " + (raw_offset/1000) / 3600 + " hours.\n");
}
public static void main(String args[]) {
DaylightSavingsTimeTest tm = new DaylightSavingsTimeTest();
tm.testDst();
}
}
Time switch that was done on Sunday April 5, 1998.
The problem existed on Solaris 2.5.1 and WinNT 4.0 using JDK 1.1.5
Essentially, the problem is that the JDK API TimeZone.getRawOffset did not switch on the Sunday (when it was supposed to) but on Monday.
Test code follows:
1) adjust your time to April 4 1998 then run it. You'll get
Current offset = to Raw offset.
2) adjust your time to April 5 1998 after 3am then run it. You'll get
Current offset = Raw offset - which is incorrect.
3) adjust your time to April 6 1998 then run it. You'll get the
correct offset - 4hrs current vs. 5hrs raw.
-------------- Source Code --------------------
import java.util.Calendar;
import java.util.TimeZone;
import java.util.Date;
public class DaylightSavingsTimeTest {
private Calendar cal;
private TimeZone tz;
public DaylightSavingsTimeTest () {
cal = Calendar.getInstance();
tz = TimeZone.getDefault();
}
public void setCal(Calendar newcal) {
cal = newcal;
}
public void setTz(TimeZone newTz) {
tz = newTz;
}
public void testDst() {
Date dt = cal.getTime();
System.err.println("Date is: "+dt+"\n");
if (tz.inDaylightTime(dt))
System.err.println("We're in Daylight Savings Time.\n");
else
System.err.println("We're not in Daylight Savings Time.\n");
int era = cal.get(Calendar.ERA);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DATE);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
int millis = cal.get(Calendar.MILLISECOND);
long offset = tz.getOffset(era, year, month, day, dayOfWeek, millis);
/*
* Current offset is correct EXCEPT for on 5 April 1998 after 3am
*/
System.err.println("Current offset is " + (offset/1000) / 3600 + " hours.\n");
long raw_offset = tz.getRawOffset();
System.err.println("Raw offset is " + (raw_offset/1000) / 3600 + " hours.\n");
}
public static void main(String args[]) {
DaylightSavingsTimeTest tm = new DaylightSavingsTimeTest();
tm.testDst();
}
}