JDK-6620374 : [TEST] test/java/text/Format/Bug4845901.java failed when System timezone set to the East of America
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 5.0u14
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris
  • CPU: sparc
  • Submitted: 2007-10-23
  • Updated: 2012-10-01
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u34Fixed 7 b126Fixed
Related Reports
Relates :  
Description
see comments

Comments
SUGGESTED FIX sccs diffs -C Bug4845901.java ------- Bug4845901.java ------- *** /tmp/sccs.bWaikD Wed Oct 24 10:30:20 2007 --- Bug4845901.java Wed Oct 24 10:29:43 2007 *************** *** 10,30 **** import java.text.SimpleDateFormat; public class Bug4845901 { - static SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS z"); public static void main (String args[]) { TimeZone savedTZ = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Australia/Sydney")); try { ! testParse("2003.01.13 11:10:00.802 EST", 11); ! testParse("2003.06.12 11:10:00.802 EST", 11); ! testParse("2004.12.24 10:10:00.002 EST", 10); ! testParse("2004.08.10 10:10:00.002 EST", 10); } finally { TimeZone.setDefault(savedTZ); } } ! static void testParse(String str, int expectedHour) { try { Date parsedDate = sdf.parse(str); if (parsedDate.getHours() != expectedHour) { --- 10,30 ---- import java.text.SimpleDateFormat; public class Bug4845901 { public static void main (String args[]) { TimeZone savedTZ = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Australia/Sydney")); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS z"); try { ! testParse(sdf, "2003.01.13 11:10:00.802 EST", 11); ! testParse(sdf, "2003.06.12 11:10:00.802 EST", 11); ! testParse(sdf, "2004.12.24 10:10:00.002 EST", 10); ! testParse(sdf, "2004.08.10 10:10:00.002 EST", 10); } finally { TimeZone.setDefault(savedTZ); } } ! static void testParse(SimpleDateFormat sdf, String str, int expectedHour) { try { Date parsedDate = sdf.parse(str); if (parsedDate.getHours() != expectedHour) {
24-10-2007

EVALUATION In the regression test, the static SimpleDateFormat instance must be created after setting the default time zone to Australia/Sydney. SimpleDateFormat.parse tries the embedded time zone first. The static SimpleDateFormat has America/New_York which has "EST" as the abbreviation for the standard time.
24-10-2007