JDK-4402769 : Setting hour as 2 for Apr 1, 2001, CDT does not set it as 2 - gets set as 1
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2001-01-08
  • Updated: 2001-01-10
  • Resolved: 2001-01-10
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 01/08/2001


java version "1.2.2"
Classic VM (build JDK-1.2.2-001, native threads, symcjit)

If we create a Gregorian calendar and the set the date to 1st April, 2001 with
the hour as 2, the hour field does not get set as 2 - it gets set as 1. And so
when we do a get(Calendar.HOUR_OF_DAY) a value of 1 is returned - not the 2 that
we set. This behaviour seems to be limited only to the value 2.


import java.util.*;

public class CheckCal {

    public static void main(String[] args) {

	Calendar c = new GregorianCalendar();
	int h = 2;

        System.out.println("Setting hour as - " + h);
	c.set(2001,3,1,h,2);

	int hr = c.get(Calendar.HOUR_OF_DAY);
	System.out.println("Date - " + c.getTime());
	
	System.out.println("Hour = " + hr);
    }
}

Setting hour as - 3
Date - Sun Apr 01 03:02:39 CDT 2001
Hour = 3

Setting hour as - 0
Date - Sun Apr 01 00:02:07 CDT 2001
Hour = 0

Setting hour as - 2
Date - Sun Apr 01 01:02:28 CDT 2001
Hour = 1
(Review ID: 114742) 
======================================================================

Comments
EVALUATION This is the same kind of daylight transition problem. Closing as a duplicate of 4312621. masayoshi.okutsu@Eng 2001-01-10
10-01-2001