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
}
}