Calendar类实现了公历日历,GregorianCalendar是Calendar类的一个具体实现。
Calendar 的getInstance()方法返回一个默认用当前的语言环境和时区初始化的GregorianCalendar对象。GregorianCalendar定义了两个字段:AD和BC。这些代表公历定义的两个时代。
GregorianCalendar对象的几个构造方法:
序号 |
构造函数和说明 |
1 |
GregorianCalendar() |
2 |
GregorianCalendar(int year, int month, int date) |
3 |
GregorianCalendar(int year, int month, int date, int hour, int minute) |
4 |
GregorianCalendar(int year, int month, int date, int hour, int minute, int second) |
5 |
GregorianCalendar(Locale aLocale) |
6 |
GregorianCalendar(TimeZone zone) |
7 |
GregorianCalendar(TimeZone zone, Locale aLocale) |
GregorianCalendar 类提供的方法列表:
序号 |
方法和说明 |
1 |
void add(int field, int amount) |
2 |
protected void computeFields() |
3 |
protected void computeTime() |
4 |
boolean equals(Object obj) |
5 |
int get(int field) |
6 |
int getActualMaximum(int field) |
7 |
int getActualMinimum(int field) |
8 |
int getGreatestMinimum(int field) |
9 |
Date getGregorianChange() |
10 |
int getLeastMaximum(int field) |
11 |
int getMaximum(int field) |
12 |
Date getTime() |
13 |
long getTimeInMillis() |
14 |
TimeZone getTimeZone() |
15 |
int getMinimum(int field) |
16 |
int hashCode() |
17 |
boolean isLeapYear(int year) |
18 |
void roll(int field, boolean up) |
19 |
void set(int field, int value) |
20 |
void set(int year, int month, int date) |
21 |
void set(int year, int month, int date, int hour, int minute) |
22 |
void set(int year, int month, int date, int hour, int minute, int second) |
23 |
void setGregorianChange(Date date) |
24 |
void setTime(Date date) |
25 |
void setTimeInMillis(long millis) |
26 |
void setTimeZone(TimeZone value) |
27 |
String toString() |