Package org.joda.time.chrono
Class GregorianChronology
java.lang.Object
org.joda.time.Chronology
org.joda.time.chrono.BaseChronology
org.joda.time.chrono.AssembledChronology
org.joda.time.chrono.BasicChronology
org.joda.time.chrono.BasicGJChronology
org.joda.time.chrono.GregorianChronology
- All Implemented Interfaces:
Serializable
Implements a pure proleptic Gregorian calendar system, which defines every
fourth year as leap, unless the year is divisible by 100 and not by 400.
This improves upon the Julian calendar leap year rule.
Although the Gregorian calendar did not exist before 1582 CE, this chronology assumes it did, thus it is proleptic. This implementation also fixes the start of the year at January 1, and defines the year zero.
GregorianChronology is thread-safe and immutable.
- Since:
- 1.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.joda.time.chrono.AssembledChronology
AssembledChronology.Fields -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ConcurrentHashMap<DateTimeZone, GregorianChronology[]> Cache of zone to chronology arraysprivate static final intprivate static final GregorianChronologySingleton instance of a UTC GregorianChronologyprivate static final intThe highest year that can be fully supported.private static final longprivate static final longprivate static final intThe lowest year that can be fully supported.private static final longSerialization lock -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateGregorianChronology(Chronology base, Object param, int minDaysInFirstWeek) Restricted constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassemble(AssembledChronology.Fields fields) Invoked by the constructor and after deserialization to allow subclasses to define all of its supported fields.(package private) longcalculateFirstDayOfYearMillis(int year) Gets the millisecond value of the first day of the year.(package private) longReturns a constant representing the approximate number of milliseconds elapsed from year 0 of this chronology, divided by two.(package private) longGets an average value for the milliseconds per month.(package private) longGets an average value for the milliseconds per year.(package private) longGets an average value for the milliseconds per year, divided by two.static GregorianChronologyGets an instance of the GregorianChronology in the default time zone.static GregorianChronologygetInstance(DateTimeZone zone) Gets an instance of the GregorianChronology in the given time zone.static GregorianChronologygetInstance(DateTimeZone zone, int minDaysInFirstWeek) Gets an instance of the GregorianChronology in the given time zone.static GregorianChronologyGets an instance of the GregorianChronology.(package private) intGets the maximum supported year.(package private) intGets the minimum supported year.(package private) booleanisLeapYear(int year) Is the specified year a leap year?private ObjectSerialization singletonwithUTC()Gets the Chronology in the UTC time zone.withZone(DateTimeZone zone) Gets the Chronology in a specific time zone.Methods inherited from class org.joda.time.chrono.BasicGJChronology
getDaysInMonthMax, getDaysInMonthMaxForSet, getDaysInYearMonth, getMonthOfYear, getTotalMillisByYearMonth, getYearDifference, isLeapDay, setYearMethods inherited from class org.joda.time.chrono.BasicChronology
equals, getDateMidnightMillis, getDateTimeMillis, getDateTimeMillis, getDayOfMonth, getDayOfMonth, getDayOfMonth, getDayOfWeek, getDayOfYear, getDayOfYear, getDaysInMonthMax, getDaysInMonthMax, getDaysInYear, getDaysInYearMax, getFirstWeekOfYearMillis, getMaxMonth, getMaxMonth, getMillisOfDay, getMinimumDaysInFirstWeek, getMonthOfYear, getWeekOfWeekyear, getWeekOfWeekyear, getWeeksInYear, getWeekyear, getYear, getYearMillis, getYearMonthDayMillis, getYearMonthMillis, getZone, hashCode, toStringMethods inherited from class org.joda.time.chrono.AssembledChronology
centuries, centuryOfEra, clockhourOfDay, clockhourOfHalfday, dayOfMonth, dayOfWeek, dayOfYear, days, era, eras, getBase, getDateTimeMillis, getParam, halfdayOfDay, halfdays, hourOfDay, hourOfHalfday, hours, millis, millisOfDay, millisOfSecond, minuteOfDay, minuteOfHour, minutes, monthOfYear, months, secondOfDay, secondOfMinute, seconds, weekOfWeekyear, weeks, weekyear, weekyearOfCentury, weekyears, year, yearOfCentury, yearOfEra, years
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization lock- See Also:
-
MILLIS_PER_YEAR
private static final long MILLIS_PER_YEAR- See Also:
-
MILLIS_PER_MONTH
private static final long MILLIS_PER_MONTH- See Also:
-
DAYS_0000_TO_1970
private static final int DAYS_0000_TO_1970- See Also:
-
MIN_YEAR
private static final int MIN_YEARThe lowest year that can be fully supported.- See Also:
-
MAX_YEAR
private static final int MAX_YEARThe highest year that can be fully supported.- See Also:
-
INSTANCE_UTC
Singleton instance of a UTC GregorianChronology -
cCache
Cache of zone to chronology arrays
-
-
Constructor Details
-
GregorianChronology
Restricted constructor
-
-
Method Details
-
getInstanceUTC
Gets an instance of the GregorianChronology. The time zone of the returned instance is UTC.- Returns:
- a singleton UTC instance of the chronology
-
getInstance
Gets an instance of the GregorianChronology in the default time zone.- Returns:
- a chronology in the default time zone
-
getInstance
Gets an instance of the GregorianChronology in the given time zone.- Parameters:
zone- the time zone to get the chronology in, null is default- Returns:
- a chronology in the specified time zone
-
getInstance
Gets an instance of the GregorianChronology in the given time zone.- Parameters:
zone- the time zone to get the chronology in, null is defaultminDaysInFirstWeek- minimum number of days in first week of the year; default is 4- Returns:
- a chronology in the specified time zone
-
readResolve
Serialization singleton -
withUTC
Gets the Chronology in the UTC time zone.- Specified by:
withUTCin classBaseChronology- Returns:
- the chronology in UTC
-
withZone
Gets the Chronology in a specific time zone.- Specified by:
withZonein classBaseChronology- Parameters:
zone- the zone to get the chronology in, null is default- Returns:
- the chronology
- See Also:
-
assemble
Description copied from class:AssembledChronologyInvoked by the constructor and after deserialization to allow subclasses to define all of its supported fields. All unset fields default to unsupported instances.- Overrides:
assemblein classBasicChronology- Parameters:
fields- container of fields
-
isLeapYear
boolean isLeapYear(int year) Description copied from class:BasicChronologyIs the specified year a leap year?- Specified by:
isLeapYearin classBasicChronology- Parameters:
year- the year to test- Returns:
- true if leap
-
calculateFirstDayOfYearMillis
long calculateFirstDayOfYearMillis(int year) Description copied from class:BasicChronologyGets the millisecond value of the first day of the year.- Specified by:
calculateFirstDayOfYearMillisin classBasicChronology- Returns:
- the milliseconds for the first of the year
-
getMinYear
int getMinYear()Description copied from class:BasicChronologyGets the minimum supported year.- Specified by:
getMinYearin classBasicChronology- Returns:
- the year
-
getMaxYear
int getMaxYear()Description copied from class:BasicChronologyGets the maximum supported year.- Specified by:
getMaxYearin classBasicChronology- Returns:
- the year
-
getAverageMillisPerYear
long getAverageMillisPerYear()Description copied from class:BasicChronologyGets an average value for the milliseconds per year.- Specified by:
getAverageMillisPerYearin classBasicChronology- Returns:
- the millis per year
-
getAverageMillisPerYearDividedByTwo
long getAverageMillisPerYearDividedByTwo()Description copied from class:BasicChronologyGets an average value for the milliseconds per year, divided by two.- Specified by:
getAverageMillisPerYearDividedByTwoin classBasicChronology- Returns:
- the millis per year divided by two
-
getAverageMillisPerMonth
long getAverageMillisPerMonth()Description copied from class:BasicChronologyGets an average value for the milliseconds per month.- Specified by:
getAverageMillisPerMonthin classBasicChronology- Returns:
- the millis per month
-
getApproxMillisAtEpochDividedByTwo
long getApproxMillisAtEpochDividedByTwo()Description copied from class:BasicChronologyReturns a constant representing the approximate number of milliseconds elapsed from year 0 of this chronology, divided by two. This constant must be defined as:(yearAtEpoch * averageMillisPerYear + millisOfYearAtEpoch) / 2where epoch is 1970-01-01 (Gregorian).- Specified by:
getApproxMillisAtEpochDividedByTwoin classBasicChronology
-