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

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.2
    • Fix Version/s: 5.0
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b28
    • CPU:
      generic, x86
    • OS:
      generic, windows_2000
    • Verification:
      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

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: