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

Problem setting time zone for GregorianCalendar.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs



      Name: gm110360 Date: 04/05/2004


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

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

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


      ADDITIONAL OS VERSION INFORMATION :
      Linux xxxx.amazon.com 2.4.21-1a #1 Thu Jul 3 15:47:32 PDT 2003 i686 unknown

      A DESCRIPTION OF THE PROBLEM :
      It seems that creating a new GregorianCalendar and then calling setTimeZone() before calling getTimeInMillis() causes the date to be changed. Please take a look at the included example.

      This is happening with all versions of Java that I have tested.

      Thanks!
      Kevin Regan
      ###@###.###


      REGRESSION. Last worked in version tiger-beta

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the included program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      1083438000000
      1083438000000

      ACTUAL -
      1083438000000
      1083412800000

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Calendar;
      import java.util.GregorianCalendar;
      import java.util.TimeZone;

      public class TimeTest {

          public static void main(String[] args) {

              Calendar calendar = new GregorianCalendar(2004, 4, 1, 12, 0);
              calendar.getTimeInMillis();
              calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
              System.out.println(calendar.getTimeInMillis());

              Calendar calendar2 = new GregorianCalendar(2004, 4, 1, 12, 0);
              calendar2.setTimeZone(TimeZone.getTimeZone("GMT"));
              System.out.println(calendar2.getTimeInMillis());

          }

      } // TimeTest
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The Calendar.getTimeInMillis() method must be called before the Calendar.setTimeZone() method.
      (Incident Review ID: 246417)
      ======================================================================

            okutsu Masayoshi Okutsu
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: