-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
1.2.0
-
sparc
-
solaris_2.5
Name: avC70361 Date: 07/06/98
SimpleTimeZone.inDaylightTime(Date) works wrong when SimpleTimeZone has DST
rules but having DST offset that is 0. It returns false for a date during DST.
Here is a test demonstrating the bug.
---------------
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
public class InDaylightTimeTest {
public static void main(String args[]) {
SimpleTimeZone tz = new SimpleTimeZone(
60 * 60 * 1000, "stz",
Calendar.JANUARY, 1, 0, 0, /* DST start day: January, 1, 0:00 */
Calendar.APRIL, 1, 0, 0, /* DST end day: April, 1, 0:00 */
0
);
Calendar calendar = new GregorianCalendar(tz);
// setting a date during DST
calendar.clear();
calendar.set(Calendar.ERA, GregorianCalendar.AD);
calendar.set(Calendar.YEAR, 1998);
calendar.set(Calendar.MONTH, Calendar.FEBRUARY);
calendar.set(Calendar.DATE, 1);
calendar.set(Calendar.HOUR, 0);
Date date = calendar.getTime();
if (!tz.inDaylightTime(date)) {
System.out.println(
"tz = " + tz + "\n" +
"date = " + date + "\n" +
"Failed. inDaylightTime(date) returns false for a date during DST"
);
} else {
System.out.println("Passed");
}
}
}
---------The test output--------
> java InDaylightTimeTest
tz = java.util.SimpleTimeZone[id=stz,offset=3600000,dstSavings=0,useDaylight=true,startYear=0,startMode=1,startMonth=0,startDay=1,startDayOfWeek=0,startTime=0,endMode=1,endMonth=3,endDay=1,endDayOfWeek=0,endTime=0]
date = Sun Feb 01 02:00:00 GMT+03:00 1998
Failed. inDaylightTime(date) returns false for a date during DST
======================================================================