JDK-5031170 : 1.3.1_11 only: GregorianCalendar uses wrong ERA value in non-lenient mode
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.3.1_11,1.3.1_13
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.5.1,solaris_9,windows_xp
  • CPU: other,x86,sparc
  • Submitted: 2004-04-13
  • Updated: 2009-06-25
  • Resolved: 2004-11-21
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.
Other
1.3.1_14 b01Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
Name: wm7046			Date: 04/13/2004


The following testcase fails in JDK 1.3.1_11 only. It might be a regression.

import java.text.SimpleDateFormat;
import java.util.Date;

SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
sdf.setLenient(false);
Date d1 = sdf.parse("2004.04.02");
Date d2 = sdf.parse("2004.04.06");
System.out.println("A date value in PST zone:" + d1.toString());
System.out.println("A date value in PDT zone:" + d2.toString());

OR
@ To make the test complete:
@ .
@ SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
@ sdf2.setLenient(false);
@ String s1 = sdf2.format(d1);
@ String s2 = sdf2.format(d2);
@ System.out.println("Canonical version of d1:" + s1);
@ System.out.println("Canonical version of d2:" + s2);
@ .
@ Above test case will return "2004/04/02 00:00:00" for d1, and
@ "2004/04/06 01:00:00" for d2.
@ Ideally, both conversions should return 00:00:00 as the time component.
(Incident Review ID: 249946) 
======================================================================
###@###.### 10/11/04 18:36 GMT

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3.1_14 FIXED IN: 1.3.1_14
02-10-2004

EVALUATION There was an oversight in the 4953991 fix. In non-lenient mode, GregorianCalendar.computeTime() doesn't call timeToFields(). Then, 0 is used as its ERA value for calling TimeZone.getOffset(). The 'era' value must be set to the ERA field before the getOffset call in non-lenient. ###@###.### 2004-04-14
14-04-2004

WORK AROUND Name: wm7046 Date: 04/13/2004 using JDK 1.3.1_09 or JDK 1.4; not using 1.3.1_11 ====================================================================== The test program works correctly in lenient mode. ###@###.### 2004-04-14
14-04-2004