java.util
Class GregorianCalendar

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.Calendar sample code for java.util.Calendar definition code for java.util.Calendar 
      extended by java.util.GregorianCalendar
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , Comparable sample code for java.lang.Comparable definition code for java.lang.Comparable <Calendar sample code for java.util.Calendar definition code for java.util.Calendar >

public class GregorianCalendar
extends Calendar sample code for java.util.Calendar definition code for java.util.Calendar

GregorianCalendar is a concrete subclass of Calendar and provides the standard calendar system used by most of the world.

GregorianCalendar is a hybrid calendar that supports both the Julian and Gregorian calendar systems with the support of a single discontinuity, which corresponds by default to the Gregorian date when the Gregorian calendar was instituted (October 15, 1582 in some countries, later in others). The cutover date may be changed by the caller by calling setGregorianChange() sample code for java.util.GregorianCalendar.setGregorianChange(java.util.Date) definition code for java.util.GregorianCalendar.setGregorianChange(java.util.Date) .

Historically, in those countries which adopted the Gregorian calendar first, October 4, 1582 (Julian) was thus followed by October 15, 1582 (Gregorian). This calendar models this correctly. Before the Gregorian cutover, GregorianCalendar implements the Julian calendar. The only difference between the Gregorian and the Julian calendar is the leap year rule. The Julian calendar specifies leap years every four years, whereas the Gregorian calendar omits century years which are not divisible by 400.

GregorianCalendar implements proleptic Gregorian and Julian calendars. That is, dates are computed by extrapolating the current rules indefinitely far backward and forward in time. As a result, GregorianCalendar may be used for all years to generate meaningful and consistent results. However, dates obtained using GregorianCalendar are historically accurate only from March 1, 4 AD onward, when modern Julian calendar rules were adopted. Before this date, leap year rules were applied irregularly, and before 45 BC the Julian calendar did not even exist.

Prior to the institution of the Gregorian calendar, New Year's Day was March 25. To avoid confusion, this calendar always uses January 1. A manual adjustment may be made if desired for dates that are prior to the Gregorian changeover and which fall between January 1 and March 24.

Values calculated for the WEEK_OF_YEAR field range from 1 to 53. Week 1 for a year is the earliest seven day period starting on getFirstDayOfWeek() that contains at least getMinimalDaysInFirstWeek() days from that year. It thus depends on the values of getMinimalDaysInFirstWeek(), getFirstDayOfWeek(), and the day of the week of January 1. Weeks between week 1 of one year and week 1 of the following year are numbered sequentially from 2 to 52 or 53 (as needed).

For example, January 1, 1998 was a Thursday. If getFirstDayOfWeek() is MONDAY and getMinimalDaysInFirstWeek() is 4 (these are the values reflecting ISO 8601 and many national standards), then week 1 of 1998 starts on December 29, 1997, and ends on January 4, 1998. If, however, getFirstDayOfWeek() is SUNDAY, then week 1 of 1998 starts on January 4, 1998, and ends on January 10, 1998; the first three days of 1998 then are part of week 53 of 1997.

Values calculated for the WEEK_OF_MONTH field range from 0 to 6. Week 1 of a month (the days with WEEK_OF_MONTH = 1) is the earliest set of at least getMinimalDaysInFirstWeek() contiguous days in that month, ending on the day before getFirstDayOfWeek(). Unlike week 1 of a year, week 1 of a month may be shorter than 7 days, need not start on getFirstDayOfWeek(), and will not include days of the previous month. Days of a month before week 1 have a WEEK_OF_MONTH of 0.

For example, if getFirstDayOfWeek() is SUNDAY and getMinimalDaysInFirstWeek() is 4, then the first week of January 1998 is Sunday, January 4 through Saturday, January 10. These days have a WEEK_OF_MONTH of 1. Thursday, January 1 through Saturday, January 3 have a WEEK_OF_MONTH of 0. If getMinimalDaysInFirstWeek() is changed to 3, then January 1 through January 3 have a WEEK_OF_MONTH of 1.

The clear methods set calendar field(s) undefined. GregorianCalendar uses the following default value for each calendar field if its value is undefined.

Field
Default Value
ERA
AD
YEAR
1970
MONTH
JANUARY
DAY_OF_MONTH
1
DAY_OF_WEEK
the first day of week
WEEK_OF_MONTH
0
DAY_OF_WEEK_IN_MONTH
1
AM_PM
AM
HOUR, HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND
0

Default values are not applicable for the fields not listed above.

Example:

 // get the supported ids for GMT-08:00 (Pacific Standard Time)
 String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
 // if no ids were returned, something is wrong. get out.
 if (ids.length == 0)
     System.exit(0);

  // begin output
 System.out.println("Current Time");

 // create a Pacific Standard Time time zone
 SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);

 // set up rules for daylight savings time
 pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
 pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);

 // create a GregorianCalendar with the Pacific Daylight time zone
 // and the current date and time
 Calendar calendar = new GregorianCalendar(pdt);
 Date trialTime = new Date();
 calendar.setTime(trialTime);

 // print out a bunch of interesting things
 System.out.println("ERA: " + calendar.get(Calendar.ERA));
 System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
 System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
 System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
 System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
 System.out.println("DATE: " + calendar.get(Calendar.DATE));
 System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
 System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
 System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
 System.out.println("DAY_OF_WEEK_IN_MONTH: "
                    + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
 System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));
 System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
 System.out.println("HOUR_OF_DAY: " + calendar.get(Calendar.HOUR_OF_DAY));
 System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
 System.out.println("SECOND: " + calendar.get(Calendar.SECOND));
 System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND));
 System.out.println("ZONE_OFFSET: "
                    + (calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000)));
 System.out.println("DST_OFFSET: "
                    + (calendar.get(Calendar.DST_OFFSET)/(60*60*1000)));

 System.out.println("Current Time, with hour reset to 3");
 calendar.clear(Calendar.HOUR_OF_DAY); // so doesn't override
 calendar.set(Calendar.HOUR, 3);
 System.out.println("ERA: " + calendar.get(Calendar.ERA));
 System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
 System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
 System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
 System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
 System.out.println("DATE: " + calendar.get(Calendar.DATE));
 System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
 System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
 System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
 System.out.println("DAY_OF_WEEK_IN_MONTH: "
                    + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
 System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));
 System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
 System.out.println("HOUR_OF_DAY: " + calendar.get(Calendar.HOUR_OF_DAY));
 System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
 System.out.println("SECOND: " + calendar.get(Calendar.SECOND));
 System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND));
 System.out.println("ZONE_OFFSET: "
        + (calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000))); // in hours
 System.out.println("DST_OFFSET: "
        + (calendar.get(Calendar.DST_OFFSET)/(60*60*1000))); // in hours
 

Since:
JDK1.1
See Also:
TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone , Serialized Form

Field Summary
static int AD sample code for java.util.GregorianCalendar.AD definition code for java.util.GregorianCalendar.AD
          Value of the ERA field indicating the common era (Anno Domini), also known as CE.
static int BC sample code for java.util.GregorianCalendar.BC definition code for java.util.GregorianCalendar.BC
          Value of the ERA field indicating the period before the common era (before Christ), also known as BCE.
 
Fields inherited from class java.util.Calendar sample code for java.util.Calendar definition code for java.util.Calendar
AM sample code for java.util.Calendar.AM definition code for java.util.Calendar.AM , AM_PM sample code for java.util.Calendar.AM_PM definition code for java.util.Calendar.AM_PM , APRIL sample code for java.util.Calendar.APRIL definition code for java.util.Calendar.APRIL , areFieldsSet sample code for java.util.Calendar.areFieldsSet definition code for java.util.Calendar.areFieldsSet , AUGUST sample code for java.util.Calendar.AUGUST definition code for java.util.Calendar.AUGUST , DATE sample code for java.util.Calendar.DATE definition code for java.util.Calendar.DATE , DAY_OF_MONTH sample code for java.util.Calendar.DAY_OF_MONTH definition code for java.util.Calendar.DAY_OF_MONTH , DAY_OF_WEEK sample code for java.util.Calendar.DAY_OF_WEEK definition code for java.util.Calendar.DAY_OF_WEEK , DAY_OF_WEEK_IN_MONTH sample code for java.util.Calendar.DAY_OF_WEEK_IN_MONTH definition code for java.util.Calendar.DAY_OF_WEEK_IN_MONTH , DAY_OF_YEAR sample code for java.util.Calendar.DAY_OF_YEAR definition code for java.util.Calendar.DAY_OF_YEAR , DECEMBER sample code for java.util.Calendar.DECEMBER definition code for java.util.Calendar.DECEMBER , DST_OFFSET sample code for java.util.Calendar.DST_OFFSET definition code for java.util.Calendar.DST_OFFSET , ERA sample code for java.util.Calendar.ERA definition code for java.util.Calendar.ERA , FEBRUARY sample code for java.util.Calendar.FEBRUARY definition code for java.util.Calendar.FEBRUARY , FIELD_COUNT sample code for java.util.Calendar.FIELD_COUNT definition code for java.util.Calendar.FIELD_COUNT , fields sample code for java.util.Calendar.fields definition code for java.util.Calendar.fields , FRIDAY sample code for java.util.Calendar.FRIDAY definition code for java.util.Calendar.FRIDAY , HOUR sample code for java.util.Calendar.HOUR definition code for java.util.Calendar.HOUR , HOUR_OF_DAY sample code for java.util.Calendar.HOUR_OF_DAY definition code for java.util.Calendar.HOUR_OF_DAY , isSet sample code for java.util.Calendar.isSet definition code for java.util.Calendar.isSet , isTimeSet sample code for java.util.Calendar.isTimeSet definition code for java.util.Calendar.isTimeSet , JANUARY sample code for java.util.Calendar.JANUARY definition code for java.util.Calendar.JANUARY , JULY sample code for java.util.Calendar.JULY definition code for java.util.Calendar.JULY , JUNE sample code for java.util.Calendar.JUNE definition code for java.util.Calendar.JUNE , MARCH sample code for java.util.Calendar.MARCH definition code for java.util.Calendar.MARCH , MAY sample code for java.util.Calendar.MAY definition code for java.util.Calendar.MAY , MILLISECOND sample code for java.util.Calendar.MILLISECOND definition code for java.util.Calendar.MILLISECOND , MINUTE sample code for java.util.Calendar.MINUTE definition code for java.util.Calendar.MINUTE , MONDAY sample code for java.util.Calendar.MONDAY definition code for java.util.Calendar.MONDAY , MONTH sample code for java.util.Calendar.MONTH definition code for java.util.Calendar.MONTH , NOVEMBER sample code for java.util.Calendar.NOVEMBER definition code for java.util.Calendar.NOVEMBER , OCTOBER sample code for java.util.Calendar.OCTOBER definition code for java.util.Calendar.OCTOBER , PM sample code for java.util.Calendar.PM definition code for java.util.Calendar.PM , SATURDAY sample code for java.util.Calendar.SATURDAY definition code for java.util.Calendar.SATURDAY , SECOND sample code for java.util.Calendar.SECOND definition code for java.util.Calendar.SECOND , SEPTEMBER sample code for java.util.Calendar.SEPTEMBER definition code for java.util.Calendar.SEPTEMBER , SUNDAY sample code for java.util.Calendar.SUNDAY definition code for java.util.Calendar.SUNDAY , THURSDAY sample code for java.util.Calendar.THURSDAY definition code for java.util.Calendar.THURSDAY , time sample code for java.util.Calendar.time definition code for java.util.Calendar.time , TUESDAY sample code for java.util.Calendar.TUESDAY definition code for java.util.Calendar.TUESDAY , UNDECIMBER sample code for java.util.Calendar.UNDECIMBER definition code for java.util.Calendar.UNDECIMBER , WEDNESDAY sample code for java.util.Calendar.WEDNESDAY definition code for java.util.Calendar.WEDNESDAY , WEEK_OF_MONTH sample code for java.util.Calendar.WEEK_OF_MONTH definition code for java.util.Calendar.WEEK_OF_MONTH , WEEK_OF_YEAR sample code for java.util.Calendar.WEEK_OF_YEAR definition code for java.util.Calendar.WEEK_OF_YEAR , YEAR sample code for java.util.Calendar.YEAR definition code for java.util.Calendar.YEAR , ZONE_OFFSET sample code for java.util.Calendar.ZONE_OFFSET definition code for java.util.Calendar.ZONE_OFFSET
 
Constructor Summary
GregorianCalendar sample code for java.util.GregorianCalendar.GregorianCalendar() definition code for java.util.GregorianCalendar.GregorianCalendar() ()
          Constructs a default GregorianCalendar using the current time in the default time zone with the default locale.
GregorianCalendar sample code for java.util.GregorianCalendar.GregorianCalendar(int, int, int) definition code for java.util.GregorianCalendar.GregorianCalendar(int, int, int) (int year, int month, int dayOfMonth)
          Constructs a GregorianCalendar with the given date set in the default time zone with the default locale.
GregorianCalendar sample code for java.util.GregorianCalendar.GregorianCalendar(int, int, int, int, int) definition code for java.util.GregorianCalendar.GregorianCalendar(int, int, int, int, int) (int year, int month, int dayOfMonth, int hourOfDay, int minute)
          Constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale.
GregorianCalendar sample code for java.util.GregorianCalendar.GregorianCalendar(int, int, int, int, int, int) definition code for java.util.GregorianCalendar.GregorianCalendar(int, int, int, int, int, int) (int year, int month, int dayOfMonth, int hourOfDay, int minute, int second)
          Constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale.
GregorianCalendar sample code for java.util.GregorianCalendar.GregorianCalendar(java.util.Locale) definition code for java.util.GregorianCalendar.GregorianCalendar(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  aLocale)
          Constructs a GregorianCalendar based on the current time in the default time zone with the given locale.
GregorianCalendar sample code for java.util.GregorianCalendar.GregorianCalendar(java.util.TimeZone) definition code for java.util.GregorianCalendar.GregorianCalendar(java.util.TimeZone) (TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone  zone)
          Constructs a GregorianCalendar based on the current time in the given time zone with the default locale.
GregorianCalendar sample code for java.util.GregorianCalendar.GregorianCalendar(java.util.TimeZone, java.util.Locale) definition code for java.util.GregorianCalendar.GregorianCalendar(java.util.TimeZone, java.util.Locale) (TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone  zone, Locale sample code for java.util.Locale definition code for java.util.Locale  aLocale)
          Constructs a GregorianCalendar based on the current time in the given time zone with the given locale.
 
Method Summary
 void add sample code for java.util.GregorianCalendar.add(int, int) definition code for java.util.GregorianCalendar.add(int, int) (int field, int amount)
          Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.
 Object sample code for java.lang.Object definition code for java.lang.Object clone sample code for java.util.GregorianCalendar.clone() definition code for java.util.GregorianCalendar.clone() ()
          Creates and returns a copy of this object.
protected  void computeFields sample code for java.util.GregorianCalendar.computeFields() definition code for java.util.GregorianCalendar.computeFields() ()
          Converts the time value (millisecond offset from the Epoch) to calendar field values.
protected  void computeTime sample code for java.util.GregorianCalendar.computeTime() definition code for java.util.GregorianCalendar.computeTime() ()
          Converts calendar field values to the time value (millisecond offset from the Epoch).
 boolean equals sample code for java.util.GregorianCalendar.equals(java.lang.Object) definition code for java.util.GregorianCalendar.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Compares this GregorianCalendar to the specified Object.
 int getActualMaximum sample code for java.util.GregorianCalendar.getActualMaximum(int) definition code for java.util.GregorianCalendar.getActualMaximum(int) (int field)
          Returns the maximum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek sample code for java.util.Calendar.getFirstDayOfWeek() definition code for java.util.Calendar.getFirstDayOfWeek() , getMinimalDaysInFirstWeek sample code for java.util.Calendar.getMinimalDaysInFirstWeek() definition code for java.util.Calendar.getMinimalDaysInFirstWeek() , getGregorianChange and getTimeZone sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone() methods.
 int getActualMinimum sample code for java.util.GregorianCalendar.getActualMinimum(int) definition code for java.util.GregorianCalendar.getActualMinimum(int) (int field)
          Returns the minimum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek sample code for java.util.Calendar.getFirstDayOfWeek() definition code for java.util.Calendar.getFirstDayOfWeek() , getMinimalDaysInFirstWeek sample code for java.util.Calendar.getMinimalDaysInFirstWeek() definition code for java.util.Calendar.getMinimalDaysInFirstWeek() , getGregorianChange and getTimeZone sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone() methods.
 int getGreatestMinimum sample code for java.util.GregorianCalendar.getGreatestMinimum(int) definition code for java.util.GregorianCalendar.getGreatestMinimum(int) (int field)
          Returns the highest minimum value for the given calendar field of this GregorianCalendar instance.
 Date sample code for java.util.Date definition code for java.util.Date getGregorianChange sample code for java.util.GregorianCalendar.getGregorianChange() definition code for java.util.GregorianCalendar.getGregorianChange() ()
          Gets the Gregorian Calendar change date.
 int getLeastMaximum sample code for java.util.GregorianCalendar.getLeastMaximum(int) definition code for java.util.GregorianCalendar.getLeastMaximum(int) (int field)
          Returns the lowest maximum value for the given calendar field of this GregorianCalendar instance.
 int getMaximum sample code for java.util.GregorianCalendar.getMaximum(int) definition code for java.util.GregorianCalendar.getMaximum(int) (int field)
          Returns the maximum value for the given calendar field of this GregorianCalendar instance.
 int getMinimum sample code for java.util.GregorianCalendar.getMinimum(int) definition code for java.util.GregorianCalendar.getMinimum(int) (int field)
          Returns the minimum value for the given calendar field of this GregorianCalendar instance.
 TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone getTimeZone sample code for java.util.GregorianCalendar.getTimeZone() definition code for java.util.GregorianCalendar.getTimeZone() ()
          Gets the time zone.
 int hashCode sample code for java.util.GregorianCalendar.hashCode() definition code for java.util.GregorianCalendar.hashCode() ()
          Generates the hash code for this GregorianCalendar object.
 boolean isLeapYear sample code for java.util.GregorianCalendar.isLeapYear(int) definition code for java.util.GregorianCalendar.isLeapYear(int) (int year)
          Determines if the given year is a leap year.
 void roll sample code for java.util.GregorianCalendar.roll(int, boolean) definition code for java.util.GregorianCalendar.roll(int, boolean) (int field, boolean up)
          Adds or subtracts (up/down) a single unit of time on the given time field without changing larger fields.
 void roll sample code for java.util.GregorianCalendar.roll(int, int) definition code for java.util.GregorianCalendar.roll(int, int) (int field, int amount)
          Adds a signed amount to the specified calendar field without changing larger fields.
 void setGregorianChange sample code for java.util.GregorianCalendar.setGregorianChange(java.util.Date) definition code for java.util.GregorianCalendar.setGregorianChange(java.util.Date) (Date sample code for java.util.Date definition code for java.util.Date  date)
          Sets the GregorianCalendar change date.
 void setTimeZone sample code for java.util.GregorianCalendar.setTimeZone(java.util.TimeZone) definition code for java.util.GregorianCalendar.setTimeZone(java.util.TimeZone) (TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone  zone)
          Sets the time zone with the given time zone value.
 
Methods inherited from class java.util.Calendar sample code for java.util.Calendar definition code for java.util.Calendar
after sample code for java.util.Calendar.after(java.lang.Object) definition code for java.util.Calendar.after(java.lang.Object) , before sample code for java.util.Calendar.before(java.lang.Object) definition code for java.util.Calendar.before(java.lang.Object) , clear sample code for java.util.Calendar.clear() definition code for java.util.Calendar.clear() , clear sample code for java.util.Calendar.clear(int) definition code for java.util.Calendar.clear(int) , compareTo sample code for java.util.Calendar.compareTo(java.util.Calendar) definition code for java.util.Calendar.compareTo(java.util.Calendar) , complete sample code for java.util.Calendar.complete() definition code for java.util.Calendar.complete() , get sample code for java.util.Calendar.get(int) definition code for java.util.Calendar.get(int) , getAvailableLocales sample code for java.util.Calendar.getAvailableLocales() definition code for java.util.Calendar.getAvailableLocales() , getFirstDayOfWeek sample code for java.util.Calendar.getFirstDayOfWeek() definition code for java.util.Calendar.getFirstDayOfWeek() , getInstance sample code for java.util.Calendar.getInstance() definition code for java.util.Calendar.getInstance() , getInstance sample code for java.util.Calendar.getInstance(java.util.Locale) definition code for java.util.Calendar.getInstance(java.util.Locale) , getInstance sample code for java.util.Calendar.getInstance(java.util.TimeZone) definition code for java.util.Calendar.getInstance(java.util.TimeZone) , getInstance sample code for java.util.Calendar.getInstance(java.util.TimeZone, java.util.Locale) definition code for java.util.Calendar.getInstance(java.util.TimeZone, java.util.Locale) , getMinimalDaysInFirstWeek sample code for java.util.Calendar.getMinimalDaysInFirstWeek() definition code for java.util.Calendar.getMinimalDaysInFirstWeek() , getTime sample code for java.util.Calendar.getTime() definition code for java.util.Calendar.getTime() , getTimeInMillis sample code for java.util.Calendar.getTimeInMillis() definition code for java.util.Calendar.getTimeInMillis() , internalGet sample code for java.util.Calendar.internalGet(int) definition code for java.util.Calendar.internalGet(int) , isLenient sample code for java.util.Calendar.isLenient() definition code for java.util.Calendar.isLenient() , isSet sample code for java.util.Calendar.isSet(int) definition code for java.util.Calendar.isSet(int) , set sample code for java.util.Calendar.set(int, int) definition code for java.util.Calendar.set(int, int) , set sample code for java.util.Calendar.set(int, int, int) definition code for java.util.Calendar.set(int, int, int) , set sample code for java.util.Calendar.set(int, int, int, int, int) definition code for java.util.Calendar.set(int, int, int, int, int) , set sample code for java.util.Calendar.set(int, int, int, int, int, int) definition code for java.util.Calendar.set(int, int, int, int, int, int) , setFirstDayOfWeek sample code for java.util.Calendar.setFirstDayOfWeek(int) definition code for java.util.Calendar.setFirstDayOfWeek(int) , setLenient sample code for java.util.Calendar.setLenient(boolean) definition code for java.util.Calendar.setLenient(boolean) , setMinimalDaysInFirstWeek sample code for java.util.Calendar.setMinimalDaysInFirstWeek(int) definition code for java.util.Calendar.setMinimalDaysInFirstWeek(int) , setTime sample code for java.util.Calendar.setTime(java.util.Date) definition code for java.util.Calendar.setTime(java.util.Date) , setTimeInMillis sample code for java.util.Calendar.setTimeInMillis(long) definition code for java.util.Calendar.setTimeInMillis(long) , toString sample code for java.util.Calendar.toString() definition code for java.util.Calendar.toString()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

BC sample code for java.util.GregorianCalendar.BC

public static final int BC
Value of the ERA field indicating the period before the common era (before Christ), also known as BCE. The sequence of years at the transition from BC to AD is ..., 2 BC, 1 BC, 1 AD, 2 AD,...

See Also:
Calendar.ERA sample code for java.util.Calendar.ERA definition code for java.util.Calendar.ERA , Constant Field Values

AD sample code for java.util.GregorianCalendar.AD

public static final int AD
Value of the ERA field indicating the common era (Anno Domini), also known as CE. The sequence of years at the transition from BC to AD is ..., 2 BC, 1 BC, 1 AD, 2 AD,...

See Also:
Calendar.ERA sample code for java.util.Calendar.ERA definition code for java.util.Calendar.ERA , Constant Field Values
Constructor Detail

GregorianCalendar sample code for java.util.GregorianCalendar() definition code for java.util.GregorianCalendar()

public GregorianCalendar()
Constructs a default GregorianCalendar using the current time in the default time zone with the default locale.


GregorianCalendar sample code for java.util.GregorianCalendar(java.util.TimeZone) definition code for java.util.GregorianCalendar(java.util.TimeZone)

public GregorianCalendar(TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone  zone)
Constructs a GregorianCalendar based on the current time in the given time zone with the default locale.

Parameters:
zone - the given time zone.

GregorianCalendar sample code for java.util.GregorianCalendar(java.util.Locale) definition code for java.util.GregorianCalendar(java.util.Locale)

public GregorianCalendar(Locale sample code for java.util.Locale definition code for java.util.Locale  aLocale)
Constructs a GregorianCalendar based on the current time in the default time zone with the given locale.

Parameters:
aLocale - the given locale.

GregorianCalendar sample code for java.util.GregorianCalendar(java.util.TimeZone, java.util.Locale) definition code for java.util.GregorianCalendar(java.util.TimeZone, java.util.Locale)

public GregorianCalendar(TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone  zone,
                         Locale sample code for java.util.Locale definition code for java.util.Locale  aLocale)
Constructs a GregorianCalendar based on the current time in the given time zone with the given locale.

Parameters:
zone - the given time zone.
aLocale - the given locale.

GregorianCalendar sample code for java.util.GregorianCalendar(int, int, int) definition code for java.util.GregorianCalendar(int, int, int)

public GregorianCalendar(int year,
                         int month,
                         int dayOfMonth)
Constructs a GregorianCalendar with the given date set in the default time zone with the default locale.

Parameters:
year - the value used to set the YEAR calendar field in the calendar.
month - the value used to set the MONTH calendar field in the calendar. Month value is 0-based. e.g., 0 for January.
dayOfMonth - the value used to set the DAY_OF_MONTH calendar field in the calendar.

GregorianCalendar sample code for java.util.GregorianCalendar(int, int, int, int, int) definition code for java.util.GregorianCalendar(int, int, int, int, int)

public GregorianCalendar(int year,
                         int month,
                         int dayOfMonth,
                         int hourOfDay,
                         int minute)
Constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale.

Parameters:
year - the value used to set the YEAR calendar field in the calendar.
month - the value used to set the MONTH calendar field in the calendar. Month value is 0-based. e.g., 0 for January.
dayOfMonth - the value used to set the DAY_OF_MONTH calendar field in the calendar.
hourOfDay - the value used to set the HOUR_OF_DAY calendar field in the calendar.
minute - the value used to set the MINUTE calendar field in the calendar.

GregorianCalendar sample code for java.util.GregorianCalendar(int, int, int, int, int, int) definition code for java.util.GregorianCalendar(int, int, int, int, int, int)

public GregorianCalendar(int year,
                         int month,
                         int dayOfMonth,
                         int hourOfDay,
                         int minute,
                         int second)
Constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale.

Parameters:
year - the value used to set the YEAR calendar field in the calendar.
month - the value used to set the MONTH calendar field in the calendar. Month value is 0-based. e.g., 0 for January.
dayOfMonth - the value used to set the DAY_OF_MONTH calendar field in the calendar.
hourOfDay - the value used to set the HOUR_OF_DAY calendar field in the calendar.
minute - the value used to set the MINUTE calendar field in the calendar.
second - the value used to set the SECOND calendar field in the calendar.
Method Detail

setGregorianChange sample code for java.util.GregorianCalendar.setGregorianChange(java.util.Date) definition code for java.util.GregorianCalendar.setGregorianChange(java.util.Date)

public void setGregorianChange(Date sample code for java.util.Date definition code for java.util.Date  date)
Sets the GregorianCalendar change date. This is the point when the switch from Julian dates to Gregorian dates occurred. Default is October 15, 1582 (Gregorian). Previous to this, dates will be in the Julian calendar.

To obtain a pure Julian calendar, set the change date to Date(Long.MAX_VALUE). To obtain a pure Gregorian calendar, set the change date to Date(Long.MIN_VALUE).

Parameters:
date - the given Gregorian cutover date.

getGregorianChange sample code for java.util.GregorianCalendar.getGregorianChange() definition code for java.util.GregorianCalendar.getGregorianChange()

public final Date sample code for java.util.Date definition code for java.util.Date  getGregorianChange()
Gets the Gregorian Calendar change date. This is the point when the switch from Julian dates to Gregorian dates occurred. Default is October 15, 1582 (Gregorian). Previous to this, dates will be in the Julian calendar.

Returns:
the Gregorian cutover date for this GregorianCalendar object.

isLeapYear sample code for java.util.GregorianCalendar.isLeapYear(int) definition code for java.util.GregorianCalendar.isLeapYear(int)

public boolean isLeapYear(int year)
Determines if the given year is a leap year. Returns true if the given year is a leap year. To specify BC year numbers, 1 - year number must be given. For example, year BC 4 is specified as -3.

Parameters:
year - the given year.
Returns:
true if the given year is a leap year; false otherwise.

equals sample code for java.util.GregorianCalendar.equals(java.lang.Object) definition code for java.util.GregorianCalendar.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Compares this GregorianCalendar to the specified Object. The result is true if and only if the argument is a GregorianCalendar object that represents the same time value (millisecond offset from the Epoch) under the same Calendar parameters and Gregorian change date as this object.

Overrides:
equals sample code for java.util.Calendar.equals(java.lang.Object) definition code for java.util.Calendar.equals(java.lang.Object) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
obj - the object to compare with.
Returns:
true if this object is equal to obj; false otherwise.
See Also:
Calendar.compareTo(Calendar) sample code for java.util.Calendar.compareTo(java.util.Calendar) definition code for java.util.Calendar.compareTo(java.util.Calendar)

hashCode sample code for java.util.GregorianCalendar.hashCode() definition code for java.util.GregorianCalendar.hashCode()

public int hashCode()
Generates the hash code for this GregorianCalendar object.

Overrides:
hashCode sample code for java.util.Calendar.hashCode() definition code for java.util.Calendar.hashCode() in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

add sample code for java.util.GregorianCalendar.add(int, int) definition code for java.util.GregorianCalendar.add(int, int)

public void add(int field,
                int amount)
Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.

Add rule 1. The value of field after the call minus the value of field before the call is amount, modulo any overflow that has occurred in field. Overflow occurs when a field value exceeds its range and, as a result, the next larger field is incremented or decremented and the field value is adjusted back into its range.

Add rule 2. If a smaller field is expected to be invariant, but it is impossible for it to be equal to its prior value because of changes in its minimum or maximum after field is changed, then its value is adjusted to be as close as possible to its expected value. A smaller field represents a smaller unit of time. HOUR is a smaller field than DAY_OF_MONTH. No adjustment is made to smaller fields that are not expected to be invariant. The calendar system determines what fields are expected to be invariant.

Specified by:
add sample code for java.util.Calendar.add(int, int) definition code for java.util.Calendar.add(int, int) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
field - the calendar field.
amount - the amount of date or time to be added to the field.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if field is ZONE_OFFSET, DST_OFFSET, or unknown, or if any calendar fields have out-of-range values in non-lenient mode.
See Also:
Calendar.roll(int,int) sample code for java.util.Calendar.roll(int, int) definition code for java.util.Calendar.roll(int, int) , Calendar.set(int,int) sample code for java.util.Calendar.set(int, int) definition code for java.util.Calendar.set(int, int)

roll sample code for java.util.GregorianCalendar.roll(int, boolean) definition code for java.util.GregorianCalendar.roll(int, boolean)

public void roll(int field,
                 boolean up)
Adds or subtracts (up/down) a single unit of time on the given time field without changing larger fields.

Example: Consider a GregorianCalendar originally set to December 31, 1999. Calling roll(Calendar.MONTH, true) sample code for java.util.GregorianCalendar.roll(int, boolean) definition code for java.util.GregorianCalendar.roll(int, boolean) sets the calendar to January 31, 1999. The YEAR field is unchanged because it is a larger field than MONTH.

Specified by:
roll sample code for java.util.Calendar.roll(int, boolean) definition code for java.util.Calendar.roll(int, boolean) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
up - indicates if the value of the specified calendar field is to be rolled up or rolled down. Use true if rolling up, false otherwise.
field - the time field.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if field is ZONE_OFFSET, DST_OFFSET, or unknown, or if any calendar fields have out-of-range values in non-lenient mode.
See Also:
add(int,int) sample code for java.util.GregorianCalendar.add(int, int) definition code for java.util.GregorianCalendar.add(int, int) , Calendar.set(int,int) sample code for java.util.Calendar.set(int, int) definition code for java.util.Calendar.set(int, int)

roll sample code for java.util.GregorianCalendar.roll(int, int) definition code for java.util.GregorianCalendar.roll(int, int)

public void roll(int field,
                 int amount)
Adds a signed amount to the specified calendar field without changing larger fields. A negative roll amount means to subtract from field without changing larger fields. If the specified amount is 0, this method performs nothing.

This method calls Calendar.complete() sample code for java.util.Calendar.complete() definition code for java.util.Calendar.complete() before adding the amount so that all the calendar fields are normalized. If there is any calendar field having an out-of-range value in non-lenient mode, then an IllegalArgumentException is thrown.

Example: Consider a GregorianCalendar originally set to August 31, 1999. Calling roll(Calendar.MONTH, 8) sets the calendar to April 30, 1999. Using a GregorianCalendar, the DAY_OF_MONTH field cannot be 31 in the month April. DAY_OF_MONTH is set to the closest possible value, 30. The YEAR field maintains the value of 1999 because it is a larger field than MONTH.

Example: Consider a GregorianCalendar originally set to Sunday June 6, 1999. Calling roll(Calendar.WEEK_OF_MONTH, -1) sets the calendar to Tuesday June 1, 1999, whereas calling add(Calendar.WEEK_OF_MONTH, -1) sets the calendar to Sunday May 30, 1999. This is because the roll rule imposes an additional constraint: The MONTH must not change when the WEEK_OF_MONTH is rolled. Taken together with add rule 1, the resultant date must be between Tuesday June 1 and Saturday June 5. According to add rule 2, the DAY_OF_WEEK, an invariant when changing the WEEK_OF_MONTH, is set to Tuesday, the closest possible value to Sunday (where Sunday is the first day of the week).

Overrides:
roll sample code for java.util.Calendar.roll(int, int) definition code for java.util.Calendar.roll(int, int) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
field - the calendar field.
amount - the signed amount to add to field.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if field is ZONE_OFFSET, DST_OFFSET, or unknown, or if any calendar fields have out-of-range values in non-lenient mode.
Since:
1.2
See Also:
roll(int,boolean) sample code for java.util.GregorianCalendar.roll(int, boolean) definition code for java.util.GregorianCalendar.roll(int, boolean) , add(int,int) sample code for java.util.GregorianCalendar.add(int, int) definition code for java.util.GregorianCalendar.add(int, int) , Calendar.set(int,int) sample code for java.util.Calendar.set(int, int) definition code for java.util.Calendar.set(int, int)

getMinimum sample code for java.util.GregorianCalendar.getMinimum(int) definition code for java.util.GregorianCalendar.getMinimum(int)

public int getMinimum(int field)
Returns the minimum value for the given calendar field of this GregorianCalendar instance. The minimum value is defined as the smallest value returned by the get sample code for java.util.Calendar.get(int) definition code for java.util.Calendar.get(int) method for any possible time value, taking into consideration the current values of the getFirstDayOfWeek sample code for java.util.Calendar.getFirstDayOfWeek() definition code for java.util.Calendar.getFirstDayOfWeek() , getMinimalDaysInFirstWeek sample code for java.util.Calendar.getMinimalDaysInFirstWeek() definition code for java.util.Calendar.getMinimalDaysInFirstWeek() , getGregorianChange and getTimeZone sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone() methods.

Specified by:
getMinimum sample code for java.util.Calendar.getMinimum(int) definition code for java.util.Calendar.getMinimum(int) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
field - the calendar field.
Returns:
the minimum value for the given calendar field.
See Also:
getMaximum(int) sample code for java.util.GregorianCalendar.getMaximum(int) definition code for java.util.GregorianCalendar.getMaximum(int) , getGreatestMinimum(int) sample code for java.util.GregorianCalendar.getGreatestMinimum(int) definition code for java.util.GregorianCalendar.getGreatestMinimum(int) , getLeastMaximum(int) sample code for java.util.GregorianCalendar.getLeastMaximum(int) definition code for java.util.GregorianCalendar.getLeastMaximum(int) , getActualMinimum(int) sample code for java.util.GregorianCalendar.getActualMinimum(int) definition code for java.util.GregorianCalendar.getActualMinimum(int) , getActualMaximum(int) sample code for java.util.GregorianCalendar.getActualMaximum(int) definition code for java.util.GregorianCalendar.getActualMaximum(int)

getMaximum sample code for java.util.GregorianCalendar.getMaximum(int) definition code for java.util.GregorianCalendar.getMaximum(int)

public int getMaximum(int field)
Returns the maximum value for the given calendar field of this GregorianCalendar instance. The maximum value is defined as the largest value returned by the get sample code for java.util.Calendar.get(int) definition code for java.util.Calendar.get(int) method for any possible time value, taking into consideration the current values of the getFirstDayOfWeek sample code for java.util.Calendar.getFirstDayOfWeek() definition code for java.util.Calendar.getFirstDayOfWeek() , getMinimalDaysInFirstWeek sample code for java.util.Calendar.getMinimalDaysInFirstWeek() definition code for java.util.Calendar.getMinimalDaysInFirstWeek() , getGregorianChange and getTimeZone sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone() methods.

Specified by:
getMaximum sample code for java.util.Calendar.getMaximum(int) definition code for java.util.Calendar.getMaximum(int) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
field - the calendar field.
Returns:
the maximum value for the given calendar field.
See Also:
getMinimum(int) sample code for java.util.GregorianCalendar.getMinimum(int) definition code for java.util.GregorianCalendar.getMinimum(int) , getGreatestMinimum(int) sample code for java.util.GregorianCalendar.getGreatestMinimum(int) definition code for java.util.GregorianCalendar.getGreatestMinimum(int) , getLeastMaximum(int) sample code for java.util.GregorianCalendar.getLeastMaximum(int) definition code for java.util.GregorianCalendar.getLeastMaximum(int) , getActualMinimum(int) sample code for java.util.GregorianCalendar.getActualMinimum(int) definition code for java.util.GregorianCalendar.getActualMinimum(int) , getActualMaximum(int) sample code for java.util.GregorianCalendar.getActualMaximum(int) definition code for java.util.GregorianCalendar.getActualMaximum(int)

getGreatestMinimum sample code for java.util.GregorianCalendar.getGreatestMinimum(int) definition code for java.util.GregorianCalendar.getGreatestMinimum(int)

public int getGreatestMinimum(int field)
Returns the highest minimum value for the given calendar field of this GregorianCalendar instance. The highest minimum value is defined as the largest value returned by getActualMinimum(int) sample code for java.util.GregorianCalendar.getActualMinimum(int) definition code for java.util.GregorianCalendar.getActualMinimum(int) for any possible time value, taking into consideration the current values of the getFirstDayOfWeek sample code for java.util.Calendar.getFirstDayOfWeek() definition code for java.util.Calendar.getFirstDayOfWeek() , getMinimalDaysInFirstWeek sample code for java.util.Calendar.getMinimalDaysInFirstWeek() definition code for java.util.Calendar.getMinimalDaysInFirstWeek() , getGregorianChange and getTimeZone sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone() methods.

Specified by:
getGreatestMinimum sample code for java.util.Calendar.getGreatestMinimum(int) definition code for java.util.Calendar.getGreatestMinimum(int) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
field - the calendar field.
Returns:
the highest minimum value for the given calendar field.
See Also:
getMinimum(int) sample code for java.util.GregorianCalendar.getMinimum(int) definition code for java.util.GregorianCalendar.getMinimum(int) , getMaximum(int) sample code for java.util.GregorianCalendar.getMaximum(int) definition code for java.util.GregorianCalendar.getMaximum(int) , getLeastMaximum(int) sample code for java.util.GregorianCalendar.getLeastMaximum(int) definition code for java.util.GregorianCalendar.getLeastMaximum(int) , getActualMinimum(int) sample code for java.util.GregorianCalendar.getActualMinimum(int) definition code for java.util.GregorianCalendar.getActualMinimum(int) , getActualMaximum(int) sample code for java.util.GregorianCalendar.getActualMaximum(int) definition code for java.util.GregorianCalendar.getActualMaximum(int)

getLeastMaximum sample code for java.util.GregorianCalendar.getLeastMaximum(int) definition code for java.util.GregorianCalendar.getLeastMaximum(int)

public int getLeastMaximum(int field)
Returns the lowest maximum value for the given calendar field of this GregorianCalendar instance. The lowest maximum value is defined as the smallest value returned by getActualMaximum(int) sample code for java.util.GregorianCalendar.getActualMaximum(int) definition code for java.util.GregorianCalendar.getActualMaximum(int) for any possible time value, taking into consideration the current values of the getFirstDayOfWeek sample code for java.util.Calendar.getFirstDayOfWeek() definition code for java.util.Calendar.getFirstDayOfWeek() , getMinimalDaysInFirstWeek sample code for java.util.Calendar.getMinimalDaysInFirstWeek() definition code for java.util.Calendar.getMinimalDaysInFirstWeek() , getGregorianChange and getTimeZone sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone() methods.

Specified by:
getLeastMaximum sample code for java.util.Calendar.getLeastMaximum(int) definition code for java.util.Calendar.getLeastMaximum(int) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
field - the calendar field
Returns:
the lowest maximum value for the given calendar field.
See Also:
getMinimum(int) sample code for java.util.GregorianCalendar.getMinimum(int) definition code for java.util.GregorianCalendar.getMinimum(int) , getMaximum(int) sample code for java.util.GregorianCalendar.getMaximum(int) definition code for java.util.GregorianCalendar.getMaximum(int) , getGreatestMinimum(int) sample code for java.util.GregorianCalendar.getGreatestMinimum(int) definition code for java.util.GregorianCalendar.getGreatestMinimum(int) , getActualMinimum(int) sample code for java.util.GregorianCalendar.getActualMinimum(int) definition code for java.util.GregorianCalendar.getActualMinimum(int) , getActualMaximum(int) sample code for java.util.GregorianCalendar.getActualMaximum(int) definition code for java.util.GregorianCalendar.getActualMaximum(int)

getActualMinimum sample code for java.util.GregorianCalendar.getActualMinimum(int) definition code for java.util.GregorianCalendar.getActualMinimum(int)

public int getActualMinimum(int field)
Returns the minimum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek sample code for java.util.Calendar.getFirstDayOfWeek() definition code for java.util.Calendar.getFirstDayOfWeek() , getMinimalDaysInFirstWeek sample code for java.util.Calendar.getMinimalDaysInFirstWeek() definition code for java.util.Calendar.getMinimalDaysInFirstWeek() , getGregorianChange and getTimeZone sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone() methods.

For example, if the Gregorian change date is January 10, 1970 and the date of this GregorianCalendar is January 20, 1970, the actual minimum value of the DAY_OF_MONTH field is 10 because the previous date of January 10, 1970 is December 27, 1996 (in the Julian calendar). Therefore, December 28, 1969 to January 9, 1970 don't exist.

Overrides:
getActualMinimum sample code for java.util.Calendar.getActualMinimum(int) definition code for java.util.Calendar.getActualMinimum(int) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
field - the calendar field
Returns:
the minimum of the given field for the time value of this GregorianCalendar
Since:
1.2
See Also:
getMinimum(int) sample code for java.util.GregorianCalendar.getMinimum(int) definition code for java.util.GregorianCalendar.getMinimum(int) , getMaximum(int) sample code for java.util.GregorianCalendar.getMaximum(int) definition code for java.util.GregorianCalendar.getMaximum(int) , getGreatestMinimum(int) sample code for java.util.GregorianCalendar.getGreatestMinimum(int) definition code for java.util.GregorianCalendar.getGreatestMinimum(int) , getLeastMaximum(int) sample code for java.util.GregorianCalendar.getLeastMaximum(int) definition code for java.util.GregorianCalendar.getLeastMaximum(int) , getActualMaximum(int) sample code for java.util.GregorianCalendar.getActualMaximum(int) definition code for java.util.GregorianCalendar.getActualMaximum(int)

getActualMaximum sample code for java.util.GregorianCalendar.getActualMaximum(int) definition code for java.util.GregorianCalendar.getActualMaximum(int)

public int getActualMaximum(int field)
Returns the maximum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek sample code for java.util.Calendar.getFirstDayOfWeek() definition code for java.util.Calendar.getFirstDayOfWeek() , getMinimalDaysInFirstWeek sample code for java.util.Calendar.getMinimalDaysInFirstWeek() definition code for java.util.Calendar.getMinimalDaysInFirstWeek() , getGregorianChange and getTimeZone sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone() methods. For example, if the date of this instance is February 1, 2004, the actual maximum value of the DAY_OF_MONTH field is 29 because 2004 is a leap year, and if the date of this instance is February 1, 2005, it's 28.

Overrides:
getActualMaximum sample code for java.util.Calendar.getActualMaximum(int) definition code for java.util.Calendar.getActualMaximum(int) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
field - the calendar field
Returns:
the maximum of the given field for the time value of this GregorianCalendar
Since:
1.2
See Also:
getMinimum(int) sample code for java.util.GregorianCalendar.getMinimum(int) definition code for java.util.GregorianCalendar.getMinimum(int) , getMaximum(int) sample code for java.util.GregorianCalendar.getMaximum(int) definition code for java.util.GregorianCalendar.getMaximum(int) , getGreatestMinimum(int) sample code for java.util.GregorianCalendar.getGreatestMinimum(int) definition code for java.util.GregorianCalendar.getGreatestMinimum(int) , getLeastMaximum(int) sample code for java.util.GregorianCalendar.getLeastMaximum(int) definition code for java.util.GregorianCalendar.getLeastMaximum(int) , getActualMinimum(int) sample code for java.util.GregorianCalendar.getActualMinimum(int) definition code for java.util.GregorianCalendar.getActualMinimum(int)

clone sample code for java.util.GregorianCalendar.clone() definition code for java.util.GregorianCalendar.clone()

public Object sample code for java.lang.Object definition code for java.lang.Object  clone()
Description copied from class: Calendar sample code for java.util.Calendar.clone() definition code for java.util.Calendar.clone()
Creates and returns a copy of this object.

Overrides:
clone sample code for java.util.Calendar.clone() definition code for java.util.Calendar.clone() in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Returns:
a copy of this object.
See Also:
Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

getTimeZone sample code for java.util.GregorianCalendar.getTimeZone() definition code for java.util.GregorianCalendar.getTimeZone()

public TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone  getTimeZone()
Description copied from class: Calendar sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone()
Gets the time zone.

Overrides:
getTimeZone sample code for java.util.Calendar.getTimeZone() definition code for java.util.Calendar.getTimeZone() in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Returns:
the time zone object associated with this calendar.

setTimeZone sample code for java.util.GregorianCalendar.setTimeZone(java.util.TimeZone) definition code for java.util.GregorianCalendar.setTimeZone(java.util.TimeZone)

public void setTimeZone(TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone  zone)
Description copied from class: Calendar sample code for java.util.Calendar.setTimeZone(java.util.TimeZone) definition code for java.util.Calendar.setTimeZone(java.util.TimeZone)
Sets the time zone with the given time zone value.

Overrides:
setTimeZone sample code for java.util.Calendar.setTimeZone(java.util.TimeZone) definition code for java.util.Calendar.setTimeZone(java.util.TimeZone) in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Parameters:
zone - the given time zone.

computeFields sample code for java.util.GregorianCalendar.computeFields() definition code for java.util.GregorianCalendar.computeFields()

protected void computeFields()
Converts the time value (millisecond offset from the Epoch) to calendar field values. The time is not recomputed first; to recompute the time, then the fields, call the complete method.

Specified by:
computeFields sample code for java.util.Calendar.computeFields() definition code for java.util.Calendar.computeFields() in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
See Also:
Calendar.complete() sample code for java.util.Calendar.complete() definition code for java.util.Calendar.complete()

computeTime sample code for java.util.GregorianCalendar.computeTime() definition code for java.util.GregorianCalendar.computeTime()

protected void computeTime()
Converts calendar field values to the time value (millisecond offset from the Epoch).

Specified by:
computeTime sample code for java.util.Calendar.computeTime() definition code for java.util.Calendar.computeTime() in class Calendar sample code for java.util.Calendar definition code for java.util.Calendar
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if any calendar fields are invalid.
See Also:
Calendar.complete() sample code for java.util.Calendar.complete() definition code for java.util.Calendar.complete() , Calendar.computeFields() sample code for java.util.Calendar.computeFields() definition code for java.util.Calendar.computeFields()