-
Bug
-
Resolution: Fixed
-
P4
-
1.4.2
-
b28
-
generic, x86
-
generic, windows_2000
-
Verified
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
}
}
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
}
}
- relates to
-
JDK-6178071 (cal) REGRESSION: GregorianCalendar.set(Calendar.HOUR, ...) has no effect
-
- Resolved
-
-
JDK-4736959 JSpinner won't work for AM/PM field
-
- Resolved
-