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

set Calendar.DAY_OF_WEEK does not work in some cases

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs



      Name: gm110360 Date: 07/28/2004


      FULL PRODUCT VERSION :
      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)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]
      (C) Copyright 1985-2000 Microsoft Corp.

      A DESCRIPTION OF THE PROBLEM :
      for:
              Calendar now = Calendar.getInstance();
              now.set(Calendar.HOUR_OF_DAY, 0);
              now.set(Calendar.DAY_OF_WEEK, now.getFirstDayOfWeek());
              System.out.println("now : " + now.getTime());

      result:
      C:\j2sdk1.4.2_04\bin\javaw.exe
      now : Sun Jul 25 00:42:11 CEST 2004

      that is OK but now :

      import java.util.Calendar;

      public class CalendarTest {
      public static void main(String[] args) {
      Calendar now = Calendar.getInstance();
      now.set(Calendar.HOUR_OF_DAY, 0);
      System.out.println("now : " + now.getTime());
      now.set(Calendar.DAY_OF_WEEK, now.getFirstDayOfWeek());
      System.out.println("now : " + now.getTime());
      }
      }

      result:
      C:\j2sdk1.4.2_04\bin\javaw.exe
      now : Wed Jul 28 00:43:47 CEST 2004
      now : Wed Jul 28 00:43:47 CEST 2004

      WRONG !!! WRONG !!! WRONG !!!

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      seems a call to get on that field before set makes the result good
      (Incident Review ID: 290116)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: