JDK-4652364 : Chatham, New Zealand, non-lenient calendar fails
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_98
  • CPU: x86
  • Submitted: 2002-03-13
  • Updated: 2002-03-14
  • Resolved: 2002-03-14
Related Reports
Duplicate :  
Description

Name: nt126004			Date: 03/13/2002


FULL PRODUCT VERSION :
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)

and 

java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)


g5.java:
tz=TimeZone.getTimeZone("Pacific/Chatham");
cal=Calendar.getInstance(tz);
cal.setLenient(false);
cal.set(Calendar.MONTH,Calendar.JUNE);

A DESCRIPTION OF THE PROBLEM :
Chatham New Zealand
is near the international
date line. Its offset is not
between -12 and +12 hours,
and is rejected by GregorianCalendar
when the Calendar is set
to non-lenient.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.get the timezone object for chatham, new zealand
2.get the (gregorian) calendar for this timezone
3.set the calendar to be non-lenient
4.set a field, such as the month, to any value

EXPECTED VERSUS ACTUAL BEHAVIOR :
GregorianCalendar.java does not
allow time zones outside of the
-12 hour to +12 hour range, but
the international date line is not
a geodesic

ERROR MESSAGES/STACK TRACES THAT OCCUR :
GregorianCalendar.java
validate arguments function
does not allow values outside of -12 hour
to 12 hour range

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
///////TZONE1.JAVA: illustrates unusual results from setting
///////   timezone to Chatham, New Zealand and calendar
///////   to non-lenient (validating) mode
///////  GregorianCalendar.java:
///////    * ZONE_OFFSET   -12*   -12*    12*     12*
///////    private static final int MIN_VALUES[] = {
///////      0,1,0,1,0,1,1,1,-1,0,0,0,0,0,0,-12*ONE_HOUR,0  };
///////    private static final int LEAST_MAX_VALUES[] = {
///////      1,292269054,11,52,4,28,365,7,4,1,11,
///////        23,59,59,999,12*ONE_HOUR,1*ONE_HOUR    };
///////    private static final int MAX_VALUES[] = {
///////      1,292278994,11,53,6,31,366,7,6,1,11,23,
///////        59,59,999,12*ONE_HOUR,1*ONE_HOUR    };
///////  Fix:  -12*ONE_HOUR and 12*ONE_HOUR should be enlarged


import java.lang.*;
import java.util.*;
import java.text.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class tzone1 extends Applet
{  private static boolean standalone=false;
   private Frame win=null;
   private TextArea ta=null;
   public void init()
   {  String msg=null;
      win=new Frame("date line time zones ");
      win.addWindowListener(
         new WindowAdapter()
         { public void windowClosing(WindowEvent we)
           { we.getWindow().dispose(); }
           public void windowClosed(WindowEvent we)
           { if (standalone) System.exit(0); }   } );
      win.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
      ta=new TextArea("",15,65);
      win.add(ta);
      win.pack();
      win.show();

      try
      { msg=getresult(); }
      catch(Throwable te)
      { msg=te.toString(); }
      ta.setText(msg);
      if (standalone) System.out.println(msg);      }
   public String getresult()
   {  String res=null;
      Calendar cal=null;
      TimeZone tz=null;
      res="";
      tz=TimeZone.getTimeZone("Pacific/Chatham");
      cal=Calendar.getInstance(tz);
      cal.setLenient(false);
      res+=cal.getTime();
      cal.set(Calendar.MONTH,Calendar.JUNE); 
      res+=cal.getTime();
      return res; }
   public static final void main(String[] args)
   {  standalone=true;
      (new tzone1()).init(); 
   } 
}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
cal.setLenient(true)
or change and recompile GregorianCalendar.java


see http://members.aol.com/FolkThomasF/MATHTXT.HTM
(Review ID: 143473) 
======================================================================

Comments
EVALUATION This is a duplicate of 4639407. ###@###.### 2002-03-14
14-03-2002