Bug in Calendar when setting time across daylight-saving boundaries?!
Martin Egholm Nielsen
martin@egholm-nielsen.dk
Tue Oct 5 09:38:00 GMT 2004
Hi Bryce,
> This patch below should fix the problem.
I just scanned the other set-methods of GCJ's Calendar. The
public final void set(int year, int month, int date)
method does not use the newly patched
public void set(int field, int value)
method. Hence, this method should either be modified to use the
patched-setter, or should be patched along the same lines you have
indicated below:
public final void set(int year, int month, int date)
{
isTimeSet = false;
fields[YEAR] = year;
fields[MONTH] = month;
fields[DATE] = date;
isSet[YEAR] = isSet[MONTH] = isSet[DATE] = true;
isSet[WEEK_OF_YEAR] = false;
isSet[DAY_OF_YEAR] = false;
isSet[WEEK_OF_MONTH] = false;
isSet[DAY_OF_WEEK] = false;
isSet[DAY_OF_WEEK_IN_MONTH] = false;
// We may have rolled over a DST boundary.
isSet[DST_OFFSET] = false;
} // set
What do you say?!
// Martin
> * java/util/Calendar.java (set): Invalidate DST_OFFSET as setting a
> calendar field may roll over a DST boundary.
>> --- Calendar.java 29 Aug 2004 17:28:09 -0000 1.23
> +++ Calendar.java 4 Oct 2004 22:02:42 -0000
> @@ -651,6 +651,10 @@
> isSet[HOUR_OF_DAY] = false;
> break;
> }
> + + // We may have rolled over a DST boundary.
> + if (field != DST_OFFSET && field != ZONE_OFFSET)
> + isSet[DST_OFFSET] = false;
> }
More information about the Java
mailing list