Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Calendar.HOUR and Calendar.HOUR_OF_DAY?

What is the difference between Calendar.HOUR and Calendar.HOUR_OF_DAY ? When to use Calendar.HOUR and Calendar.HOUR_OF_DAY ? I am confused sometime Calendar.HOUR this works fine and othertime Calendar.HOUR_OF_DAY this works fine. What they return in the form of int? I have read this documentation but not understood the difference. Any suggestions Thanks.

like image 905
Vishwesh Jainkuniya Avatar asked May 15 '16 09:05

Vishwesh Jainkuniya


1 Answers

From http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#HOUR:

Calendar.HOUR = Field number for get and set indicating the hour of the morning or afternoon. HOUR is used for the 12-hour clock. E.g., at 10:04:15.250 PM the HOUR is 10.

Calendar.HOUR_OF_DAY = Field number for get and set indicating the hour of the day. HOUR_OF_DAY is used for the 24-hour clock. E.g., at 10:04:15.250 PM the HOUR_OF_DAY is 22.

like image 188
Mrugesh Thaker Avatar answered Sep 20 '22 16:09

Mrugesh Thaker