public class GregorianCalendar extends Calendar
Calendar
,
TimeZone
,
SimpleTimeZone
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
AD
Value for the AD era.
|
static int |
BC
Value for the BC era.
|
AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
Constructor and Description |
---|
GregorianCalendar()
Constructs a new GregorianCalendar initialized to the current date and
time.
|
GregorianCalendar(int year,
int month,
int day)
Constructs a new GregorianCalendar initialized to midnight in the default
time zone on the specified date.
|
GregorianCalendar(int year,
int month,
int day,
int hour,
int minute)
Constructs a new GregorianCalendar initialized to the specified date and
time.
|
GregorianCalendar(int year,
int month,
int day,
int hour,
int minute,
int second)
Constructs a new GregorianCalendar initialized to the specified date and
time.
|
GregorianCalendar(Locale locale)
Constructs a new GregorianCalendar initialized to the current date and
time and using the specified Locale.
|
GregorianCalendar(TimeZone timezone)
Constructs a new GregorianCalendar initialized to the current date and
time and using the specified TimeZone.
|
GregorianCalendar(TimeZone timezone,
Locale locale)
Constructs a new GregorianCalendar initialized to the current date and
time and using the specified TimeZone and Locale.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int field,
int value)
Adds the specified amount to a Calendar field.
|
Object |
clone()
Creates new instance of GregorianCalendar with the same properties.
|
protected void |
computeFields()
Computes the Calendar fields from the time.
|
protected void |
computeTime()
Computes the time from the Calendar fields.
|
boolean |
equals(Object object)
Compares the specified object to this GregorianCalendar and answer if
they are equal.
|
int |
getActualMaximum(int field)
Gets the maximum value of the specified field for the current date.
|
int |
getActualMinimum(int field)
Gets the minimum value of the specified field for the current date.
|
int |
getGreatestMinimum(int field)
Gets the greatest minimum value of the specified field.
|
Date |
getGregorianChange()
Answers the gregorian change date of this calendar.
|
int |
getLeastMaximum(int field)
Gets the smallest maximum value of the specified field.
|
int |
getMaximum(int field)
Gets the greatest maximum value of the specified field.
|
int |
getMinimum(int field)
Gets the smallest minimum value of the specified field.
|
int |
hashCode()
Answers an integer hash code for the receiver.
|
boolean |
isLeapYear(int year)
Answers if the specified year is a leap year.
|
void |
roll(int field,
boolean increment)
Increment or decrement the specified field and wrap the value of the
field when it goes beyond the maximum or minimum value for the current
date.
|
void |
roll(int field,
int value)
Adds the specified amount the specified field and wrap the value of the
field when it goes beyond the maximum or minimum value for the current
date.
|
void |
setFirstDayOfWeek(int value)
Sets the first day of the week for this Calendar.
|
void |
setGregorianChange(Date date)
Sets the gregorian change date of this calendar.
|
void |
setMinimalDaysInFirstWeek(int value)
Sets the minimal days in the first week of the year.
|
after, before, clear, clear, complete, get, getAvailableLocales, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, getTimeZone, internalGet, isLenient, isSet, set, set, set, set, setLenient, setTime, setTimeInMillis, setTimeZone, toString
public static final int BC
public static final int AD
public GregorianCalendar()
public GregorianCalendar(int year, int month, int day)
year
- the yearmonth
- the monthday
- the day of the monthpublic GregorianCalendar(int year, int month, int day, int hour, int minute)
year
- the yearmonth
- the monthday
- the day of the monthhour
- the hourminute
- the minutepublic GregorianCalendar(int year, int month, int day, int hour, int minute, int second)
year
- the yearmonth
- the monthday
- the day of the monthhour
- the hourminute
- the minutesecond
- the secondpublic GregorianCalendar(Locale locale)
locale
- the Localepublic GregorianCalendar(TimeZone timezone)
timezone
- the TimeZonepublic void add(int field, int value)
add
in class Calendar
field
- the Calendar field to modifyvalue
- the amount to add to the fieldIllegalArgumentException
- when the specified field is DST_OFFSET or ZONE_OFFSET.public Object clone()
protected void computeFields()
computeFields
in class Calendar
protected void computeTime()
computeTime
in class Calendar
IllegalArgumentException
- when the time cannot be computed from the current field
valuespublic boolean equals(Object object)
equals
in class Calendar
object
- the object to compare with this objectIllegalArgumentException
- when the time is not set and the time cannot be computed
from the current field valueshashCode()
public int getActualMaximum(int field)
getActualMaximum
in class Calendar
field
- the fieldpublic int getActualMinimum(int field)
getMinimum()
.getActualMinimum
in class Calendar
field
- the fieldpublic int getGreatestMinimum(int field)
getMinimum()
.getGreatestMinimum
in class Calendar
field
- the fieldpublic final Date getGregorianChange()
public int getLeastMaximum(int field)
getLeastMaximum
in class Calendar
field
- the fieldpublic int getMaximum(int field)
getMaximum
in class Calendar
field
- the fieldpublic int getMinimum(int field)
getMinimum
in class Calendar
field
- the fieldpublic int hashCode()
hashCode
in class Calendar
equals(java.lang.Object)
public boolean isLeapYear(int year)
year
- the yearpublic void roll(int field, int value)
roll
in class Calendar
field
- the field to rollvalue
- the amount to addIllegalArgumentException
- when an invalid field is specifiedpublic void roll(int field, boolean increment)
roll
in class Calendar
field
- the field to rollincrement
- true to increment the field, false to decrementIllegalArgumentException
- when an invalid field is specifiedpublic void setGregorianChange(Date date)
date
- a Date which represents the gregorian change datepublic void setFirstDayOfWeek(int value)
Calendar
setFirstDayOfWeek
in class Calendar
value
- a Calendar day of the weekpublic void setMinimalDaysInFirstWeek(int value)
Calendar
setMinimalDaysInFirstWeek
in class Calendar
value
- the minimal days in the first week of the year