GeezerVison is showing docs.oracle.com — GregorianCalendar (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.util
Class GregorianCalendar
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
static int |
AD |
Value of the ERA field indicating
the common era (Anno Domini), also known as CE.
|
static int |
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
ALL_STYLES, 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, LONG, LONG_FORMAT, LONG_STANDALONE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NARROW_FORMAT, NARROW_STANDALONE, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SHORT, SHORT_FORMAT, SHORT_STANDALONE, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
-
Constructor Summary
Constructors
| Constructor |
Description |
GregorianCalendar() |
Constructs a default GregorianCalendar using the current time
in the default time zone with the default
FORMAT locale.
|
GregorianCalendar(int year,
int month,
int dayOfMonth) |
Constructs a GregorianCalendar with the given date set
in the default time zone with the default locale.
|
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.
|
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.
|
GregorianCalendar(Locale aLocale) |
Constructs a GregorianCalendar based on the current time
in the default time zone with the given locale.
|
GregorianCalendar(TimeZone zone) |
Constructs a GregorianCalendar based on the current time
in the given time zone with the default
FORMAT locale.
|
GregorianCalendar(TimeZone zone,
Locale aLocale) |
Constructs a GregorianCalendar based on the current time
in the given time zone with the given locale.
|
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
| Modifier and Type |
Method |
Description |
void |
add(int field,
int amount) |
Adds the specified (signed) amount of time to the given calendar field,
based on the calendar's rules.
|
Object |
clone() |
Creates and returns a copy of this object.
|
protected void |
computeFields() |
Converts the time value (millisecond offset from the Epoch) to calendar field values.
|
protected void |
computeTime() |
Converts calendar field values to the time value (millisecond
offset from the Epoch).
|
boolean |
equals(Object obj) |
Compares this GregorianCalendar to the specified
Object.
|
static GregorianCalendar |
from(ZonedDateTime zdt) |
Obtains an instance of GregorianCalendar with the default locale
from a ZonedDateTime object.
|
int |
getActualMaximum(int field) |
|
int |
getActualMinimum(int field) |
|
String |
getCalendarType() |
Returns "gregory" as the calendar type.
|
int |
getGreatestMinimum(int field) |
Returns the highest minimum value for the given calendar field
of this GregorianCalendar instance.
|
Date |
getGregorianChange() |
Gets the Gregorian Calendar change date.
|
int |
getLeastMaximum(int field) |
Returns the lowest maximum value for the given calendar field
of this GregorianCalendar instance.
|
int |
getMaximum(int field) |
Returns the maximum value for the given calendar field of this
GregorianCalendar instance.
|
int |
getMinimum(int field) |
Returns the minimum value for the given calendar field of this
GregorianCalendar instance.
|
TimeZone |
getTimeZone() |
Gets the time zone.
|
int |
getWeeksInWeekYear() |
Returns the number of weeks in the week year
represented by this GregorianCalendar.
|
int |
getWeekYear() |
Returns the week year represented by this
GregorianCalendar.
|
int |
hashCode() |
Generates the hash code for this GregorianCalendar object.
|
boolean |
isLeapYear(int year) |
Determines if the given year is a leap year.
|
boolean |
isWeekDateSupported() |
Returns true indicating this GregorianCalendar
supports week dates.
|
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.
|
void |
roll(int field,
int amount) |
Adds a signed amount to the specified calendar field without changing larger fields.
|
void |
setGregorianChange(Date date) |
Sets the GregorianCalendar change date.
|
void |
setTimeZone(TimeZone zone) |
Sets the time zone with the given time zone value.
|
void |
setWeekDate(int weekYear,
int weekOfYear,
int dayOfWeek) |
Sets this GregorianCalendar to the date given by the
date specifiers - weekYear,
weekOfYear, and dayOfWeek.
|
ZonedDateTime |
toZonedDateTime() |
Converts this object to a ZonedDateTime that represents
the same point on the time-line as this GregorianCalendar.
|
-
Methods inherited from class java.util.Calendar
after, before, clear, clear, compareTo, complete, get, getAvailableCalendarTypes, getAvailableLocales, getDisplayName, getDisplayNames, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, internalGet, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, toInstant, toString
-
-
Field Detail
-
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,
Constant Field Values
-
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,
Constant Field Values
-
Constructor Detail
-
GregorianCalendar
public GregorianCalendar(TimeZone zone,
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
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
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
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
-
getGregorianChange
public final 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
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.
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|