JDK-4945385 : java.util.GregorianCalendar.getMaximum(ZONE_OFFSET) works wrong
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2003-10-29
  • Updated: 2003-10-30
  • Resolved: 2003-10-30
Related Reports
Duplicate :  
Description

Name: sdR10048			Date: 10/29/2003


Filed By      : SPB JCK team (###@###.###)
JDK           : java full version "1.5.0-beta-b25"
JCK           : 1.5
Platform[s]   : Solaris
switch/Mode   : 
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : 
api/java_util/GregorianCalendar/index.html#SetGet[GregorianCalendar0029]
This testcase (updated version) will be in WS soon.
See 4937099 report.

Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
public int getMaximum(int field)
Returns maximum value for the given field. e.g. for Gregorian DAY_OF_MONTH, 31 Please see Calendar.getMaximum for descriptions on parameters and the return value. 

Specified by:
getMaximum in class Calendar
Parameters:
field - the given time field. 
Returns:
the maximum value for the given time field.
...
---------- end-of-excerpt ---------------

Problem description
===================
The designated method does not return valid maximum gmt offset.
There is some time zone with GMT offset greater than output value.
See demo.
    
Minimized test:
===============
------- J.java -------
import java.util.*;

public class J {

    public static void main(String[] args) {
        long time = 9223372036854775807L;
        TimeZone tz = TimeZone.getTimeZone("Pacific/Kiritimati");
        int gmtOffset = tz.getOffset(time);
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTimeInMillis(time);
        int gmtOffset2 = cal.getMaximum(Calendar.ZONE_OFFSET);
        System.out.println("Time zone gmtOffset  : "+gmtOffset);
        System.out.println("Calendar gmtOffset   : "+gmtOffset2);
    }
}

------- end-of-J.java -------

Minimized test output:
======================
C:\TEMP\1>c:\java\bin\java -showversion J
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b25)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b25, mixed mode)

Time zone gmtOffset  : 50400000
Calendar gmtOffset   : 43200000

JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests

======================================================================

Comments
EVALUATION This is a dup of 4639407. ###@###.### 2003-10-30
30-10-2003