J
Jim Garrison
Given the following class:
public class TestDate
{
public static void main(String[] args)
{
GregorianCalendar c = new GregorianCalendar();
System.out.println(c.get(Calendar.DST_OFFSET));
c.set(Calendar.YEAR,2006);
System.out.println(c.get(Calendar.DST_OFFSET));
c.set(2006, Calendar.DECEMBER, 31);
System.out.println(c.get(Calendar.DST_OFFSET));
}
}
Can someone explain why the output (when run in the CDT
timezone) is:
3600000
3600000
0
It appears that the set(int,int,int) call clears the DST_OFFSET field,
even though the API explicitly states:
public final void set(int year,
int month,
int date)
Sets the values for the calendar fields YEAR, MONTH, and
DAY_OF_MONTH. Previous values of other calendar fields are retained.
If this is not desired, call clear() first.
What am I missing?
BTW, this is with Sun JDK 1.5.0_10.
public class TestDate
{
public static void main(String[] args)
{
GregorianCalendar c = new GregorianCalendar();
System.out.println(c.get(Calendar.DST_OFFSET));
c.set(Calendar.YEAR,2006);
System.out.println(c.get(Calendar.DST_OFFSET));
c.set(2006, Calendar.DECEMBER, 31);
System.out.println(c.get(Calendar.DST_OFFSET));
}
}
Can someone explain why the output (when run in the CDT
timezone) is:
3600000
3600000
0
It appears that the set(int,int,int) call clears the DST_OFFSET field,
even though the API explicitly states:
public final void set(int year,
int month,
int date)
Sets the values for the calendar fields YEAR, MONTH, and
DAY_OF_MONTH. Previous values of other calendar fields are retained.
If this is not desired, call clear() first.
What am I missing?
BTW, this is with Sun JDK 1.5.0_10.