JDK-7021075 : (cal) DST rollover time odd behavior for some time zones
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 6u24
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2011-02-21
  • Updated: 2012-03-20
  • Resolved: 2011-03-10
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When creating a new Calendar object with a human readable Time Zone (explicitly, "America/New_York") and then setting the time in millis equal to the rollover point of DST in the fall (e.g., Nov 7, 2010 @2am Eastern...  the FIRST 2am Eastern), and then updating the Calendar object with set(field, value), the time bumps forward one hour to the second time when you'd be at this point.

See steps below, much clearer there

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Get a new Calendar instance using "America/New_York" as the Time Zone

Set the time in Millis to: 1289106000000

Evaluate the Time, both millis and Readable String...  the time is Nov 7, 2010, 5:00:00.000 GMT

Call set(Calendar.MINUTE, 0) on the object...  the minutes are already 0, so this should have no affect.

Evaluate the object again.  The millis are now "1289109600000" and it's now Nov 7, 2010, 6:00:00.000 GMT.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2010-Nov-07 05:00:00 GMT - 1289106000000
2010-Nov-07 05:00:00 GMT - 1289106000000
ACTUAL -
2010-Nov-07 05:00:00 GMT - 1289106000000
2010-Nov-07 06:00:00 GMT - 1289109600000

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class DSTTest
{
  public static void main(String[] args)
  {
    Calendar cal =
        Calendar.getInstance(TimeZone.getTimeZone("America/New_York"));

//    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("EDT"));
//NOTE: Using "EDT" instead of "America/New_York" seems to work properly

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss z");
    sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

    cal.setTimeInMillis(1289106000000l);

    System.out
        .println(sdf.format(cal.getTime()) + " - " + cal.getTimeInMillis());
    cal.set(Calendar.MINUTE, 0);
    System.out
        .println(sdf.format(cal.getTime()) + " - " + cal.getTimeInMillis());
  }
}
---------- END SOURCE ----------