JDK-6993107 : local zone setTimeZone ignores daylight
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2010-10-19
  • Updated: 2013-05-23
  • Resolved: 2013-05-23
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) Server VM (build 16.3-b01, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux hawks 2.6.26-2-686 #1 SMP Mon Jun 21 05:58:44 UTC 2010 i686 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
machine is set to the Eastern timezone

A DESCRIPTION OF THE PROBLEM :
SimplDateFormat will correctly render a date in Daylight vs Standard time for all other timezone codes EXCEPT the local Eastern timezone.  For that timezone it is either ignoring daylight time or it is using the daylight setting that is current not for the time being formatted but the time of the machine asking the question.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Given two dates, one in summer, one in fall, each specified with time zone information as GMT-0400, create two SimpleTimeFormat objects, one set to a timezone of PST, one to EST; the time rendered by the PST object will be correct for both dates, the time rendered by the EST object will only be correct for the winter date.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
clearly if PST gives the time rendered as daylight time for the summer date and standard time for the winter date, then it should do the same for the local timezone too.
ACTUAL -
instead what we see is the PST parameter gives the expected results while the EST paramter gives standard time regardless of the date.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
The following is taken from a session using the bean shell so as to show the values as they are entered and computed.  % is the bsh prompt to show those lines that are external to java

ds1 = "20100924T195100-0400";
ds2 = "20101224T195100-0400";
inp = new SimpleDateFormat("yyyyMMdd'T'HHmmssZ");
d1 = inp.parse( ds1 );
d2 = inp.parse( ds2 );
% print(d2);
Fri Dec 24 18:51:00 EST 2010
% print(d1);
Fri Sep 24 19:51:00 EDT 2010

target  = new SimpleDateFormat("yyyyMMdd'T'HHmmssZ");
target.setTimeZone(TimeZone.getTimeZone("PST");
% print( target.format( d1 ));
20100924T165100-0700
% print( target.format( d2 ));
20101224T155100-0800

so far so good but now ...
target.setTimeZone(TimeZone.getTimeZone("EST"));
% print( target.format( d1 ));
20100924T185100-0500
% print( target.format( d2 ));
20101224T185100-0500

NO DAYLIGHT TIME??

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
if there is a workaround, please let me know.  and btw, softwarereg.sun.com/services/registration/new-user is an invalid URL

Comments
Duplicate of JDK-6466476.
23-05-2013