Class BasicFixedMonthChronology

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CopticChronology, EthiopicChronology

abstract class BasicFixedMonthChronology extends BasicChronology
Abstract implementation of a calendar system based around fixed length months.

As the month length is fixed various calculations can be optimised. This implementation assumes any additional days after twelve months fall into a thirteenth month.

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

Since:
1.2, refactored from CopticChronology
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization lock
      See Also:
    • MONTH_LENGTH

      static final int MONTH_LENGTH
      The length of the month.
      See Also:
    • MILLIS_PER_YEAR

      static final long MILLIS_PER_YEAR
      The typical millis per year.
      See Also:
    • MILLIS_PER_MONTH

      static final long MILLIS_PER_MONTH
      The length of the month in millis.
      See Also:
  • Constructor Details

    • BasicFixedMonthChronology

      BasicFixedMonthChronology(Chronology base, Object param, int minDaysInFirstWeek)
      Restricted constructor.
      Parameters:
      base - the base chronology
      param - the init parameter
      minDaysInFirstWeek - the minimum days in the first week
  • Method Details

    • 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
    • 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
    • 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
    • getDayOfMonth

      int getDayOfMonth(long millis)
      Overrides:
      getDayOfMonth in class BasicChronology
      Parameters:
      millis - from 1970-01-01T00:00:00Z
    • 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
    • getDaysInYearMonth

      int getDaysInYearMonth(int year, int month)
      Description copied from class: BasicChronology
      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()
      Description copied from class: BasicChronology
      Gets the maximum number of days in any month.
      Overrides:
      getDaysInMonthMax in class BasicChronology
      Returns:
      31
    • 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
    • getMonthOfYear

      int getMonthOfYear(long millis)
      Overrides:
      getMonthOfYear in class BasicChronology
      Parameters:
      millis - from 1970-01-01T00:00:00Z
    • 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
    • getMaxMonth

      int getMaxMonth()
      Description copied from class: BasicChronology
      Gets the maximum number of months.
      Overrides:
      getMaxMonth in class BasicChronology
      Returns:
      12
    • getAverageMillisPerYear

      long getAverageMillisPerYear()
      Description copied from class: BasicChronology
      Gets an average value for the milliseconds per year.
      Specified by:
      getAverageMillisPerYear in class BasicChronology
      Returns:
      the millis per year
    • getAverageMillisPerYearDividedByTwo

      long getAverageMillisPerYearDividedByTwo()
      Description copied from class: BasicChronology
      Gets an average value for the milliseconds per year, divided by two.
      Specified by:
      getAverageMillisPerYearDividedByTwo in class BasicChronology
      Returns:
      the millis per year divided by two
    • getAverageMillisPerMonth

      long getAverageMillisPerMonth()
      Description copied from class: BasicChronology
      Gets an average value for the milliseconds per month.
      Specified by:
      getAverageMillisPerMonth in class BasicChronology
      Returns:
      the millis per month