Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4945385

java.util.GregorianCalendar.getMaximum(ZONE_OFFSET) works wrong

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • core-libs



      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

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

            okutsu Masayoshi Okutsu
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: