JDK-6961979 : GregorianCalendar returns wrong Time and TimeZone.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 6u10
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2003
  • CPU: x86
  • Submitted: 2010-06-17
  • Updated: 2013-04-09
  • Resolved: 2013-04-09
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 5.2.3790]

A DESCRIPTION OF THE PROBLEM :
I am using GregorianCalendar class to get current time.

GregorianCalendar today = new GregorianCalendar();
Date currenttime = today.getTime();

If i print "currenttime ", it is printing wrong time.

Current system time is 19:00, but it is giving 08:30 VET
The time zone of my system is "GMT+6:00 Dhaka".

Previously my system time zone was "GMT-6:00 Central Time (US & Canada)" and "Automatically adjust clock for daylight saving changes" is checked.
Here everything is fine.

Only after changing this time zone to "GMT+6:00 Dhaka", I am facing this issue.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Set the system time zone to "GMT-6:00 Central Time (US & Canada)" and check "Automatically adjust clock for daylight saving changes". Click Apply
2. Now change the time zone to "GMT+6:00 Dhaka". and click apply.

Now using the below api, print the current time.

GregorianCalendar today = new GregorianCalendar();
Date currenttime = today.getTime();


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Thu Jun 16 19:15:20 GMT+6:00 2010

ACTUAL -
Thu Jun 16 08:45:20 VET 2010

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
GregorianCalendar today = new GregorianCalendar();
Date currenttime = today.getTime();

System.out.println("Current time is = "+currenttime );
---------- END SOURCE ----------

Comments
Duplicate of 6929185 fixed in 6u21.
09-04-2013