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

Calendar: Both set() and roll() don't work for AM_PM time field

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 5.0
    • 1.4.2
    • core-libs
    • b28
    • generic, x86
    • generic, windows_2000
    • Verified

    Description

      Calendar: Both set() and roll() don't work for AM_PM time field.
      But add() works.

      Please run the attached code, the AM_PM won't change until
      add() is called.
      ------------------------------------------------------
      import java.util.*;
      import java.text.*;

      public class Test{
         public static void main(String[] args){
            
            Calendar cal = Calendar.getInstance();
            cal.clear();
            cal.set(2002, 2, 2, 10, 30, 30);
            cal.get(Calendar.YEAR);
            cal.get(Calendar.MONTH);
            cal.get(Calendar.DATE);
            cal.get(Calendar.HOUR);
            cal.get(Calendar.MINUTE);
            cal.get(Calendar.SECOND);
            System.out.println(cal.get(Calendar.AM_PM));//output 0
            
            cal.set(Calendar.AM_PM, 1);
            System.out.println(cal.get(Calendar.AM_PM));//output 0
            
            cal.roll(Calendar.AM_PM, true);
            System.out.println(cal.get(Calendar.AM_PM));//output 0
            
            cal.roll(Calendar.AM_PM, 1);
            System.out.println(cal.get(Calendar.AM_PM));//output 0
            
            cal.add(Calendar.AM_PM, 1);
            System.out.println(cal.get(Calendar.AM_PM));//output 1
            
            cal.add(Calendar.AM_PM, 1);
            System.out.println(cal.get(Calendar.AM_PM));//output 0
            
            cal.add(Calendar.AM_PM, -1);
            System.out.println(cal.get(Calendar.AM_PM));//output 1
         }
      }

      Attachments

        Issue Links

          Activity

            People

              okutsu Masayoshi Okutsu
              lzhanorcl Lichun Zhan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: