Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 5043409
Votes 0
Synopsis JDK1.3.1_11 changed the default ERA in GregorianCalendar
Category java:classes_util_i18n
Reported Against 1.3.1_11
Release Fixed
State 11-Closed, duplicate of 5031170, bug
Priority: 4-Low
Related Bugs 5031170
Submit Date 06-MAY-2004
Description




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) 
======================================================================
Work Around
N/A
Evaluation
This is a duplicate of 5031170.
  xxxxx@xxxxx   2004-05-07
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang