JDK-4846659 : Calendar: Both set() and roll() don't work for AM_PM time field
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_2000
  • CPU: generic,x86
  • Submitted: 2003-04-10
  • Updated: 2004-01-12
  • Resolved: 2003-11-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b28Fixed
Related Reports
Relates :  
Relates :  
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               
   }
}


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta FIXED IN: tiger-beta INTEGRATED IN: tiger-b28 tiger-beta VERIFIED IN: tiger-beta
14-06-2004

EVALUATION This problem happen on jdk1.4, jdk1.3.1. It is not a regression. ###@###.### 2003-04-10 This is the same problem as 4736959 for set(). Calendar doesn't take an AM_PM change if HOUR hasn't been changed together. Since roll() calls set() to set the new value, these methods have the same problem. Fixing this bug requires corrections to the JCK test cases. See 4736959 for the JCK failures with the fix. add() converts the amount to milliseconds and calculates time, and doesn't have this problem. ###@###.### 2003-04-11
11-04-2003