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

REGRESSION:Calendar get(Calendar.DAY_OF_WEEK)invalid under certain circumstances

XMLWordPrintable

    • b28
    • generic, x86
    • generic, windows_2000



      Name: rmT116609 Date: 05/08/2003


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

      FULL OS VERSION :
      debian linux 3.0

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Reproduced under sdk 1.4.2beta

      A DESCRIPTION OF THE PROBLEM :
      cal.get(Calendar.DAY_OF_WEEK) yiedls incorrect day of week if it was initialized with another day_of_week.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      TestCase available

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Should print no bug
      Calendar.MONDAY == cal.get(Calendar.DAY_OF_WEEK)
      Prints bug
      Calendar.MONDAY != cal.get(Calendar.DAY_OF_WEEK)


      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      /** Exposes a bug in sdk 1.4.2beta. Works in previous jdks*/
      public class CalendarBug {
          public static void main(String[] args) {
              // bug also encounted in other locales
              Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+0"),Locale.US);
              cal.set(Calendar.DAY_OF_WEEK,Calendar.TUESDAY);
              cal.setTime(cal.getTime());
              cal.set(Calendar.HOUR_OF_DAY,11);
              cal.getTime();
              cal.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
              if (Calendar.MONDAY != cal.get(Calendar.DAY_OF_WEEK)) {
                  System.out.println("Bug: day_of_week changed.");
              } else {
                  System.out.println("No bug.");
              }
          }
      }

      ---------- END SOURCE ----------

      Release Regression From : 1.4.1_02
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Review ID: 183562)
      ======================================================================

            okutsu Masayoshi Okutsu
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: