Can you set AM / PM to a GregorianCalendar date or is that what you can get

I looked at the java api about GregorianCalendar and did not see any way to set am / pm in its constructor. Can you set AM / PM to a GregorianCalendar date or is it something you can only use with the get method on the calendar. Does this all do this automatically. I want to take am / pm and output it to my toString for a class that has a date object. I was going to use the get method on the calendar to get this. I understand that am / pm is an int that is 0 or 1.

I was also wondering if all the hours in gregorian are 24 hours and it automatically detects am and pm?

+5
source share
2 answers
Calendar.get(Calendar.HOUR);

(0-12) AM/PM.

Calendar.get(Calendar.HOUR_OF_DAY);

0 24.

. .

cal.set( Calendar.AM_PM, Calendar.AM )

/ , . ( 1:00 1:00 AM). GregorianCalendar (. ).

Btw/Hint imo DateFormat, .

+29
Calendar cal = new GreogorianCalendar();   
cal.set( Calendar.AM_PM, Calendar.AM );
+6

All Articles