# 日历和日历之间的区别.Hour_of_day?[英] Difference between Calendar.HOUR and Calendar.HOUR_OF_DAY?

### 问题描述

Calendar.HOUR和Calendar.HOUR_OF_DAY有什么区别? 什么时候使用Calendar.HOUR和Calendar.HOUR_OF_DAY? 我很困惑Calendar.HOUR这很好，其他时间Calendar.HOUR_OF_DAY这很好.他们以INT的形式返回什么? 我已经阅读了 this 文档，但不了解差异. 有什么建议么 谢谢.

## 推荐答案

calendar.hour =获取和设置的现场编号，指示早晨或下午的小时.小时用于12小时的时钟.例如，在10:04:15.250 pm时小时为10.

calendar.hour_of_day = get和设置的字段号，指示一天中的小时. hour_of_day用于24小时时钟.例如，在10:04:15.250 pm hour_of_day为22.

## 其他推荐答案

import java.util.Calendar; import java.util.GregorianCalendar;

```public class test{  public static void main(String[] args) {
GregorianCalendar gc = new GregorianCalendar(2013, 8, 15, 21, 69,55);
```

//分钟= 69等于1小时09分钟.这个小时将增加小时地点(21+1 = 22)//Sun Sep 15 22:09:55 IST 2013

```  p(gc, Calendar.YEAR);    //gives year

p(gc, Calendar.MONTH);   // gives month staring at 0 for  January

p(gc, Calendar.DATE);    // date

p(gc, Calendar.DAY_OF_WEEK);// Sunday=1, Monday=2, .....Saturday -7

p(gc, Calendar.WEEK_OF_MONTH);//what week its running in week ,whether its first or second;

p(gc, Calendar.DAY_OF_WEEK_IN_MONTH);//In this case, How may times does Sunday is repeating in the month = 3;

p(gc, Calendar.DAY_OF_YEAR);//count of the day in the year

p(gc, Calendar.HOUR);//12 hour format. if the time is 22:09:55, answer would be (22-12)=10

p(gc, Calendar.HOUR_OF_DAY);// hour of day that is 22 (24h format)

p(gc, Calendar.MINUTE);// 09

p(gc, Calendar.SECOND);// 55

System.out.println();

System.out.println(gc.getTime());
```

}

```static void p(Calendar c, int type) {
System.out.print(c.get(type) + "-");
```

} }

*输出:

2013-8-15-1-3-3-258-10-22-9-55-

*