United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7130335 Problem with timezone in a SimpleDateFormat
JDK-7130335 : Problem with timezone in a SimpleDateFormat

Details
Type:
Bug
Submit Date:
2012-01-16
Status:
Closed
Updated Date:
2012-10-18
Project Name:
JDK
Resolved Date:
2012-08-07
Component:
core-libs
OS:
generic
Sub-Component:
java.text
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u24
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
SHORT SUMMARY:  Inaccurate date reports when using yyyy/MM/dd HH:mm:ss.S z 
date format on a Timezone with historical TZ rules
INDICATORS:  Can occur when parsing date strings with TimeZone included, the 
"z" element.
COUNTER INDICATORS:
TRIGGERS: 
SimpleDateFormat class can incorrectly calculate a DST offset when parsing 
date strings that contain the TimeZone. If the parsed TZ has used different 
rules over past years, then the hour offset from the DST calculation may be 
incorrect. In general, applications shouldn't rely on time zone abbreviations 
for parsing of date strings. e.g CST can represent different timezones across 
the globe.

KNOWN WORKAROUND: Don't use timezone abbreviations in timezones strings that 
are to be parsed. Perhaps store the timezone separately.
PRESENT SINCE: N/A
HOW TO VERIFY:
NOTES FOR SE: Dev engineer has proposed some changes to correct this. It 
should first be ported to JDK 8 and baked/tested there for compatibility 
behaviour. Once satisfied, we can port it to a JDK 6 update release.

REGRESSION:

                                    

Comments
EVALUATION

SimpleDateFormat calls TimeZone.getRawOffset() which doesn't deal with any historical GMT offset changes. It should avoid the use of the fixed GMT offset.
                                     
2012-01-16



Hardware and Software, Engineered to Work Together