With Calendar it works as follows:
//create first Calendar object
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 15); // 3 PM
// the same is
calendar.set(Calendar.AM_PM, Calendar.PM); // choose PM mode
calendar.set(Calendar.HOUR, 3); // 3 PM
System.out.println( calendar.get(Calendar.HOUR) ); // AM_PM format
System.out.println( calendar.get(Calendar.HOUR_OF_DAY) ); // 0-23 format