Class GregorianChronology

  • All Implemented Interfaces:
    java.io.Serializable

    public final class GregorianChronology
    extends BasicGJChronology
    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:
    Wikipedia, JulianChronology, GJChronology, Serialized Form
    • Constructor Detail

      • GregorianChronology

        private GregorianChronology​(Chronology base,
                                    java.lang.Object param,
                                    int minDaysInFirstWeek)
        Restricted constructor
    • Method Detail

      • getInstanceUTC

        public static GregorianChronology 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

        public static GregorianChronology getInstance()
        Gets an instance of the GregorianChronology in the default time zone.
        Returns:
        a chronology in the default time zone
      • getInstance

        public static GregorianChronology getInstance​(DateTimeZone zone)
        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

        public static GregorianChronology getInstance​(DateTimeZone zone,
                                                      int minDaysInFirstWeek)
        Gets an instance of the GregorianChronology in the given time zone.
        Parameters:
        zone - the time zone to get the chronology in, null is default
        minDaysInFirstWeek - minimum number of days in first week of the year; default is 4
        Returns:
        a chronology in the specified time zone
      • readResolve

        private java.lang.Object readResolve()
        Serialization singleton
      • withUTC

        public Chronology withUTC()
        Gets the Chronology in the UTC time zone.
        Specified by:
        withUTC in class BaseChronology
        Returns:
        the chronology in UTC
      • assemble

        protected void assemble​(AssembledChronology.Fields fields)
        Description copied from class: AssembledChronology
        Invoked by the constructor and after deserialization to allow subclasses to define all of its supported fields. All unset fields default to unsupported instances.
        Overrides:
        assemble in class BasicChronology
        Parameters:
        fields - container of fields
      • isLeapYear

        boolean isLeapYear​(int year)
        Description copied from class: BasicChronology
        Is the specified year a leap year?
        Specified by:
        isLeapYear in class BasicChronology
        Parameters:
        year - the year to test
        Returns:
        true if leap
      • calculateFirstDayOfYearMillis

        long calculateFirstDayOfYearMillis​(int year)
        Description copied from class: BasicChronology
        Gets the millisecond value of the first day of the year.
        Specified by:
        calculateFirstDayOfYearMillis in class BasicChronology
        Returns:
        the milliseconds for the first of the year
      • getApproxMillisAtEpochDividedByTwo

        long getApproxMillisAtEpochDividedByTwo()
        Description copied from class: BasicChronology
        Returns 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) / 2
         
        where epoch is 1970-01-01 (Gregorian).
        Specified by:
        getApproxMillisAtEpochDividedByTwo in class BasicChronology