Class BasicGJChronology

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    GregorianChronology, JulianChronology

    abstract class BasicGJChronology
    extends BasicChronology
    Abstract Chronology for implementing chronologies based on Gregorian/Julian formulae. Most of the utility methods required by subclasses are package-private, reflecting the intention that they be defined in the same package.

    BasicGJChronology is thread-safe and immutable, and all subclasses must be as well.

    Since:
    1.2, refactored from CommonGJChronology
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Serialization lock
        See Also:
        Constant Field Values
      • MIN_DAYS_PER_MONTH_ARRAY

        private static final int[] MIN_DAYS_PER_MONTH_ARRAY
      • MAX_DAYS_PER_MONTH_ARRAY

        private static final int[] MAX_DAYS_PER_MONTH_ARRAY
      • MIN_TOTAL_MILLIS_BY_MONTH_ARRAY

        private static final long[] MIN_TOTAL_MILLIS_BY_MONTH_ARRAY
      • MAX_TOTAL_MILLIS_BY_MONTH_ARRAY

        private static final long[] MAX_TOTAL_MILLIS_BY_MONTH_ARRAY
    • Constructor Detail

      • BasicGJChronology

        BasicGJChronology​(Chronology base,
                          java.lang.Object param,
                          int minDaysInFirstWeek)
        Constructor.
    • Method Detail

      • isLeapDay

        boolean isLeapDay​(long instant)
        Description copied from class: BasicChronology
        Is the specified instant a leap day?
        Overrides:
        isLeapDay in class BasicChronology
        Parameters:
        instant - the instant to test
        Returns:
        true if leap, default is false
      • getMonthOfYear

        int getMonthOfYear​(long millis,
                           int year)
        Specified by:
        getMonthOfYear in class BasicChronology
        Parameters:
        millis - from 1970-01-01T00:00:00Z
        year - precalculated year of millis
      • getDaysInYearMonth

        int getDaysInYearMonth​(int year,
                               int month)
        Gets the number of days in the specified month and year.
        Specified by:
        getDaysInYearMonth in class BasicChronology
        Parameters:
        year - the year
        month - the month
        Returns:
        the number of days
      • getDaysInMonthMax

        int getDaysInMonthMax​(int month)
        Description copied from class: BasicChronology
        Gets the maximum days in the specified month.
        Specified by:
        getDaysInMonthMax in class BasicChronology
        Parameters:
        month - the month
        Returns:
        the max days
      • getDaysInMonthMaxForSet

        int getDaysInMonthMaxForSet​(long instant,
                                    int value)
        Description copied from class: BasicChronology
        Gets the maximum number of days in the month specified by the instant. The value represents what the user is trying to set, and can be used to optimise this method.
        Overrides:
        getDaysInMonthMaxForSet in class BasicChronology
        Parameters:
        instant - millis from 1970-01-01T00:00:00Z
        value - the value being set
        Returns:
        the maximum number of days in the month
      • getTotalMillisByYearMonth

        long getTotalMillisByYearMonth​(int year,
                                       int month)
        Description copied from class: BasicChronology
        Gets the total number of millis elapsed in this year at the start of the specified month, such as zero for month 1.
        Specified by:
        getTotalMillisByYearMonth in class BasicChronology
        Parameters:
        year - the year
        month - the month
        Returns:
        the elapsed millis at the start of the month
      • getYearDifference

        long getYearDifference​(long minuendInstant,
                               long subtrahendInstant)
        Description copied from class: BasicChronology
        Gets the difference between the two instants in years.
        Specified by:
        getYearDifference in class BasicChronology
        Parameters:
        minuendInstant - the first instant
        subtrahendInstant - the second instant
        Returns:
        the difference
      • setYear

        long setYear​(long instant,
                     int year)
        Description copied from class: BasicChronology
        Sets the year from an instant and year.
        Specified by:
        setYear in class BasicChronology
        Parameters:
        instant - millis from 1970-01-01T00:00:00Z
        year - the year to set
        Returns:
        the updated millis