JDK-4220964 : Problem with Calendar class in MET TimeZone with daylight saving
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-03-16
  • Updated: 1999-07-30
  • Resolved: 1999-07-30
Related Reports
Duplicate :  
Description

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) 
======================================================================

Comments
PUBLIC COMMENTS Calendar.add(DAY_OF_YEAR) does not work on daylight saving switch day.
10-06-2004

EVALUATION Same problem as 4248500 koushi.takahashi@japan 1999-07-30
30-07-1999