JDK-5043409 : JDK1.3.1_11 changed the default ERA in GregorianCalendar
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.3.1_11
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-05-06
  • Updated: 2004-05-07
  • Resolved: 2004-05-07
Related Reports
Duplicate :  
Description

Name: jl125535			Date: 05/06/2004


FULL PRODUCT VERSION :
$ ./java.exe -version
java version "1.3.1_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_11-b02)
Java HotSpot(TM) Client VM (build 1.3.1_11-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
All OS's, but discovered on Windows XP

EXTRA RELEVANT SYSTEM CONFIGURATION :
Locale = EN_GB here, but I suspect it will reproduce for EN_US as well.

A DESCRIPTION OF THE PROBLEM :
A change was introduced in JDK1.3.1_11 that makes it incompatible with JDK1.3.1_09 and previous, and JDK1.4.0 and all later (up to JDK1.5.0beta1).

The Gregorian Calendar no longer takes an unset ERA into account properly when calculating the timezone offset

This is caused by the changes to the following lines (as indicated by diff on the provided source):

180c175
<  * @version      1.53
---
>  * @version      1.56
1161c1156
<         int era = internalGetEra();
---
>         int era = internalGet(ERA);
1510c1505
<             dstOffset = zone.getOffset(era,
---
>             dstOffset = zone.getOffset(internalGet(ERA),

I assume this was done as a code tidying exercise.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Consider the code in the test case.

In JDK1.3.1_09 and previous, and JDK1.4.0 and greater this code produces the output (when in EN_GB locale)

Tue May 04 05:00:00 BST 2004

In jdk1.3.1_11 only it produces the output:

Tue May 04 06:00:00 BST 2004



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Tue May 04 05:00:00 BST 2004
ACTUAL -
Tue May 04 06:00:00 BST 2004

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.*;

public class CalendarTest {
  public static void main(String [] args) {
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setLenient(false);
    calendar.clear();
    // date unimportant, but must be summer time
    calendar.set(2004, Calendar.MAY, 4, 5, 0, 0); 
//    calendar.set(Calendar.ERA, GregorianCalendar.AD);
    System.out.println(calendar.getTime());
  }
}

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

CUSTOMER SUBMITTED WORKAROUND :
Uncomment the above ERA setting line. ie a call to

calendar.set(Calendar.ERA, GregorianCalendar.AD);
(Incident Review ID: 260911) 
======================================================================

Comments
EVALUATION This is a duplicate of 5031170. ###@###.### 2004-05-07
07-05-2004