Calendar calendar = Calendar.getInstance();
System.out.println(calendar.get(Calendar.HOUR_OF_DAY)); // print hour in 24 format
Friday, September 19, 2014
How to get hour value in 24 hour format
Thursday, September 18, 2014
Java Calendar - Calendar.MONTH is zero-based
Calendar calendar = Calendar.getInstance(); calendar.set(2010, 4, 10); System.out.println(calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); System.out.println(calendar.get(Calendar.DAY_OF_MONTH));
It's weird thing calendar.set(2010, 4, 10), actually set date as May 10, 2010. "4" for the MONTH field is really misleading. It sets Month as "May".
caalendar.getActualMaximum() calculates the maximum of days in month of May.
So output should be:
31
10
Subscribe to:
Posts (Atom)