Build 1.0_r1(from source)

java.util
Class GregorianCalendar

java.lang.Object
  extended by java.util.Calendar
      extended by java.util.GregorianCalendar
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Calendar>

public class GregorianCalendar
extends Calendar

GregorianCalendar provides the conversion between Dates and integer calendar fields, such as the month, year or minute, for the Gregorian calendar. See Calendar for the defined fields.

See Also:
Calendar, TimeZone, SimpleTimeZone, Serialized Form

Field Summary
static int AD
          Value for the AD era.
static int BC
          Value for the BC era.
(package private) static byte[] DaysInMonth
           
 
Fields inherited from class java.util.Calendar
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, lastDateFieldSet, lastTimeFieldSet, 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 Summary
GregorianCalendar()
          Constructs a new GregorianCalendar initialized to the current date and time.
GregorianCalendar(boolean ignored)
           
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(long milliseconds)
           
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.
 
Method Summary
 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()
          Returns 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.
(package private)  int getOffset(long localTime)
           
 int hashCode()
          Returns an integer hash code for the receiver.
 boolean isLeapYear(int year)
          Returns 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.
 
Methods inherited from class java.util.Calendar
after, before, clear, clear, compareTo, complete, get, getAvailableLocales, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, getTimeZone, internalGet, isLenient, isSet, set, set, set, set, setLenient, setTime, setTimeInMillis, setTimeZone, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BC

public static final int BC
Value for the BC era.

See Also:
Constant Field Values

AD

public static final int AD
Value for the AD era.

See Also:
Constant Field Values

DaysInMonth

static byte[] DaysInMonth
Constructor Detail

GregorianCalendar

public GregorianCalendar()
Constructs a new GregorianCalendar initialized to the current date and time.


GregorianCalendar

public GregorianCalendar(int year,
                         int month,
                         int day)
Constructs a new GregorianCalendar initialized to midnight in the default time zone on the specified date.

Parameters:
year - the year
month - the month
day - the day of the month

GregorianCalendar

public GregorianCalendar(int year,
                         int month,
                         int day,
                         int hour,
                         int minute)
Constructs a new GregorianCalendar initialized to the specified date and time.

Parameters:
year - the year
month - the month
day - the day of the month
hour - the hour
minute - the minute

GregorianCalendar

public GregorianCalendar(int year,
                         int month,
                         int day,
                         int hour,
                         int minute,
                         int second)
Constructs a new GregorianCalendar initialized to the specified date and time.

Parameters:
year - the year
month - the month
day - the day of the month
hour - the hour
minute - the minute
second - the second

GregorianCalendar

GregorianCalendar(long milliseconds)

GregorianCalendar

public GregorianCalendar(Locale locale)
Constructs a new GregorianCalendar initialized to the current date and time and using the specified Locale.

Parameters:
locale - the Locale

GregorianCalendar

public GregorianCalendar(TimeZone timezone)
Constructs a new GregorianCalendar initialized to the current date and time and using the specified TimeZone.

Parameters:
timezone - the TimeZone

GregorianCalendar

public GregorianCalendar(TimeZone timezone,
                         Locale locale)
Constructs a new GregorianCalendar initialized to the current date and time and using the specified TimeZone and Locale.

Parameters:
timezone - the TimeZone
locale - the Locale

GregorianCalendar

GregorianCalendar(boolean ignored)
Method Detail

add

public void add(int field,
                int value)
Adds the specified amount to a Calendar field.

Specified by:
add in class Calendar
Parameters:
field - the Calendar field to modify
value - the amount to add to the field
Throws:
IllegalArgumentException - when the specified field is DST_OFFSET or ZONE_OFFSET.

clone

public Object clone()
Creates new instance of GregorianCalendar with the same properties.

Overrides:
clone in class Calendar
Returns:
a shallow copy of this GregorianCalendar
See Also:
Cloneable

computeFields

protected void computeFields()
Computes the Calendar fields from the time.

Specified by:
computeFields in class Calendar

computeTime

protected void computeTime()
Computes the time from the Calendar fields.

Specified by:
computeTime in class Calendar
Throws:
IllegalArgumentException - when the time cannot be computed from the current field values

equals

public boolean equals(Object object)
Compares the specified object to this GregorianCalendar and answer if they are equal. The object must be an instance of GregorianCalendar and have the same properties.

Overrides:
equals in class Calendar
Parameters:
object - the object to compare with this object
Returns:
true if the specified object is equal to this GregorianCalendar, false otherwise
Throws:
IllegalArgumentException - when the time is not set and the time cannot be computed from the current field values
See Also:
hashCode()

getActualMaximum

public int getActualMaximum(int field)
Gets the maximum value of the specified field for the current date. For example, the maximum number of days in the current month.

Overrides:
getActualMaximum in class Calendar
Parameters:
field - the field
Returns:
the maximum value of the specified field

getActualMinimum

public int getActualMinimum(int field)
Gets the minimum value of the specified field for the current date. For the gregorian calendar, this value is the same as getMinimum().

Overrides:
getActualMinimum in class Calendar
Parameters:
field - the field
Returns:
the minimum value of the specified field

getGreatestMinimum

public int getGreatestMinimum(int field)
Gets the greatest minimum value of the specified field. For the gregorian calendar, this value is the same as getMinimum().

Specified by:
getGreatestMinimum in class Calendar
Parameters:
field - the field
Returns:
the greatest minimum value of the specified field

getGregorianChange

public final Date getGregorianChange()
Returns the gregorian change date of this calendar. This is the date on which the gregorian calendar came into effect.

Returns:
a Date which represents the gregorian change date

getLeastMaximum

public int getLeastMaximum(int field)
Gets the smallest maximum value of the specified field. For example, 28 for the day of month field.

Specified by:
getLeastMaximum in class Calendar
Parameters:
field - the field
Returns:
the smallest maximum value of the specified field

getMaximum

public int getMaximum(int field)
Gets the greatest maximum value of the specified field. For example, 31 for the day of month field.

Specified by:
getMaximum in class Calendar
Parameters:
field - the field
Returns:
the greatest maximum value of the specified field

getMinimum

public int getMinimum(int field)
Gets the smallest minimum value of the specified field.

Specified by:
getMinimum in class Calendar
Parameters:
field - the field
Returns:
the smallest minimum value of the specified field

getOffset

int getOffset(long localTime)

hashCode

public int hashCode()
Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Overrides:
hashCode in class Calendar
Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

isLeapYear

public boolean isLeapYear(int year)
Returns if the specified year is a leap year.

Parameters:
year - the year
Returns:
true if the specified year is a leap year, false otherwise

roll

public 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. Other fields will be adjusted as required to maintain a consistent date.

Overrides:
roll in class Calendar
Parameters:
field - the field to roll
value - the amount to add
Throws:
IllegalArgumentException - when an invalid field is specified

roll

public 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. Other fields will be adjusted as required to maintain a consistent date. For example, March 31 will roll to April 30 when rolling the month field.

Specified by:
roll in class Calendar
Parameters:
field - the field to roll
increment - true to increment the field, false to decrement
Throws:
IllegalArgumentException - when an invalid field is specified

setGregorianChange

public void setGregorianChange(Date date)
Sets the gregorian change date of this calendar.

Parameters:
date - a Date which represents the gregorian change date

setFirstDayOfWeek

public void setFirstDayOfWeek(int value)
Description copied from class: Calendar
Sets the first day of the week for this Calendar.

Overrides:
setFirstDayOfWeek in class Calendar
Parameters:
value - a Calendar day of the week

setMinimalDaysInFirstWeek

public void setMinimalDaysInFirstWeek(int value)
Description copied from class: Calendar
Sets the minimal days in the first week of the year.

Overrides:
setMinimalDaysInFirstWeek in class Calendar
Parameters:
value - the minimal days in the first week of the year

Build 1.0_r1(from source)

Please submit a feedback, bug or feature