Name: gsC80088 Date: 03/16/99
When adding one DAY_OF_YEAR to a Calendar positioned a day
before a daylight saving changement the increment is badly
performed in MET (an probably other) timezone (MET is in this
case the real Java one, not Solaris ONE).
For example if you have this date :
1998 March 20th 00:00:00 GMT+3.3
and you do a Calendar.add(DAY_OF_YEAR, 1), you will get
1998 March 20th 23:00:00 GMT+3.3
The day IS EXACTLY the same !! This is probably due to the fact
that the 00:00:00 hour doesn't exist (daylight saving) in 1998
March 21th. But the result should be :
1998 March 21th 01:00:00 GMT+4.4 (because 00:00:00 doesn't exist).
instead of not changing the real day !
Here is an example showing the problem :
import java.util.*;
import java.text.*;
public class Time01 {
public static void main(String[] arg) {
TimeZone.setDefault(TimeZone.getTimeZone("MET"));
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.LONG);
Calendar cal = Calendar.getInstance();
cal.set(1998, Calendar.MARCH, 20, 0, 0);
System.err.println("Start Time : "+df.format(cal.getTime()));
cal.add(Calendar.DAY_OF_YEAR, 1);
System.err.println("One Day Later "+df.format(cal.getTime()));
cal.add(Calendar.DAY_OF_YEAR, 1);
System.err.println("One more "+df.format(cal.getTime()));
}
}
(Review ID: 53551)
======================================================================