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

Setting hour as 2 for Apr 1, 2001, CDT does not set it as 2 - gets set as 1

XMLWordPrintable

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



      Name: rmT116609 Date: 01/08/2001


      java version "1.2.2"
      Classic VM (build JDK-1.2.2-001, native threads, symcjit)

      If we create a Gregorian calendar and the set the date to 1st April, 2001 with
      the hour as 2, the hour field does not get set as 2 - it gets set as 1. And so
      when we do a get(Calendar.HOUR_OF_DAY) a value of 1 is returned - not the 2 that
      we set. This behaviour seems to be limited only to the value 2.


      import java.util.*;

      public class CheckCal {

          public static void main(String[] args) {

      Calendar c = new GregorianCalendar();
      int h = 2;

              System.out.println("Setting hour as - " + h);
      c.set(2001,3,1,h,2);

      int hr = c.get(Calendar.HOUR_OF_DAY);
      System.out.println("Date - " + c.getTime());

      System.out.println("Hour = " + hr);
          }
      }

      Setting hour as - 3
      Date - Sun Apr 01 03:02:39 CDT 2001
      Hour = 3

      Setting hour as - 0
      Date - Sun Apr 01 00:02:07 CDT 2001
      Hour = 0

      Setting hour as - 2
      Date - Sun Apr 01 01:02:28 CDT 2001
      Hour = 1
      (Review ID: 114742)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: