Calendar.HOUR 和 Calendar.HOUR_OF_DAY 之间的区别?

2022-01-11 00:00:00 calendar android java

Calendar.HOURCalendar.HOUR_OF_DAY 有什么区别?何时使用 Calendar.HOURCalendar.HOUR_OF_DAY ?有时我很困惑 Calendar.HOUR 这工作正常,而其他时候 Calendar.HOUR_OF_DAY 这工作正常.他们以 int 的形式返回什么?我已阅读 this 文档,但不明白其中的区别.有什么建议谢谢.

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.

推荐答案

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

Calendar.HOUR = get 和 set 字段编号,指示上午或下午的时间.HOUR 用于 12 小时制.例如,在晚上 10:04:15.250,HOUR 是 10.

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 = get 和 set 字段编号,指示一天中的小时.HOUR_OF_DAY 用于 24 小时制.例如,在晚上 10:04:15.250,HOUR_OF_DAY 是 22.

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.

相关文章