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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37236381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 19:06:46  来源:igfitidea点击:

Difference between Calendar.HOUR and Calendar.HOUR_OF_DAY?

javaandroidcalendar

提问by Vishwesh Jainkuniya

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

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

采纳答案by Mrugesh Thaker

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

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.

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

Calendar.HOUR_OF_DAY = 用于获取和设置指示一天中的小时的字段编号。HOUR_OF_DAY 用于 24 小时制。例如,在晚上 10:04:15.250,HOUR_OF_DAY 是 22。