Class HistoricChronology
- java.lang.Object
-
- javax.time.calendar.Chronology
-
- javax.time.i18n.HistoricChronology
-
- All Implemented Interfaces:
java.io.Serializable,Calendrical
public final class HistoricChronology extends Chronology implements java.io.Serializable
The Historic calendar system.HistoricChronology defines the rules of the Historic calendar system. The Historic calendar has twelve months of 30 days followed by an additional period of 5 or 6 days, modelled as the thirteenth month in this implementation.
Years are measured in the 'Era of the Martyrs'. 0001-01-01 (Historic) equals 0284-08-29 (ISO). The supported range is from Historic year 1 to year 9999 (inclusive).
HistoricChronology is immutable and thread-safe.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classHistoricChronology.DayOfMonthRuleRule implementation.private static classHistoricChronology.DayOfWeekRuleRule implementation.private static classHistoricChronology.DayOfYearRuleRule implementation.private static classHistoricChronology.EraRuleRule implementation.private static classHistoricChronology.MonthOfYearRuleRule implementation.private static classHistoricChronology.MonthsUnit class for months.private static classHistoricChronology.YearRuleRule implementation.private static classHistoricChronology.YearsUnit class for years.
-
Field Summary
Fields Modifier and Type Field Description private LocalDatecutoverThe cutover from Julian to Gregorian.private static int[]LEAP_MONTH_STARTThe start of months in a leap year.private static PeriodUnitMONTHSPeriod unit for months.private static longserialVersionUIDA serialization identifier for this class.private static int[]STANDARD_MONTH_STARTThe start of months in a standard year.private static PeriodUnitYEARSPeriod unit for years.
-
Constructor Summary
Constructors Modifier Constructor Description privateHistoricChronology(LocalDate cutover)Restrictive constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static voidcheckNotNull(java.lang.Object object, java.lang.String errorMessage)Validates that the input value is not null.static HistoricChronologycutoverAt(LocalDate cutover)Obtains an instance ofHistoricChronologyspecifying the cutover date when the Gregorian/ISO calendar system was first used.DateTimeFieldRule<java.lang.Integer>dayOfMonthRule()Gets the rule for the day-of-month field in the Historic chronology.DateTimeFieldRule<DayOfWeek>dayOfWeekRule()Gets the rule for the day-of-week field in the Historic chronology.DateTimeFieldRule<java.lang.Integer>dayOfYearRule()Gets the rule for the day-of-year field in the Historic chronology.DateTimeFieldRule<HistoricEra>eraRule()Gets the rule for the year field in the Historic chronology.LocalDategetCutover()Gets the cutover date of the chronology.(package private) HistoricDategetDateFromDayOfYear(int year, int dayOfYear)Calculates the date from a year and day-of-year.(package private) intgetDayOfYear(HistoricDate date)Calculates the day-of-year from a date.java.lang.StringgetName()Gets the name of the chronology.booleanisLeapYear(int year)Checks if the specified year is a leap year.DateTimeFieldRule<MonthOfYear>monthOfYearRule()Gets the rule for the month-of-year field in the Historic chronology.static PeriodUnitperiodDays()Gets the period unit for days.static PeriodUnitperiodEras()Gets the period unit for eras.static PeriodUnitperiodMonths()Gets the period unit for months.static PeriodUnitperiodWeeks()Gets the period unit for weeks.static PeriodUnitperiodYears()Gets the period unit for years.static HistoricChronologystandardCutover()Obtains an instance ofHistoricChronologyusing the standard cutover date of 1582-10-15.DateTimeFieldRule<java.lang.Integer>yearOfEraRule()Gets the rule for the year field in the Historic chronology.DateTimeFieldRule<java.lang.Integer>yearRule()Gets the rule for the year field in the Historic chronology.-
Methods inherited from class javax.time.calendar.Chronology
get, rule, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
A serialization identifier for this class.- See Also:
- Constant Field Values
-
STANDARD_MONTH_START
private static final int[] STANDARD_MONTH_START
The start of months in a standard year.
-
LEAP_MONTH_START
private static final int[] LEAP_MONTH_START
The start of months in a leap year.
-
cutover
private final LocalDate cutover
The cutover from Julian to Gregorian.
-
YEARS
private static final PeriodUnit YEARS
Period unit for years.
-
MONTHS
private static final PeriodUnit MONTHS
Period unit for months.
-
-
Constructor Detail
-
HistoricChronology
private HistoricChronology(LocalDate cutover)
Restrictive constructor.
-
-
Method Detail
-
cutoverAt
public static HistoricChronology cutoverAt(LocalDate cutover)
Obtains an instance ofHistoricChronologyspecifying the cutover date when the Gregorian/ISO calendar system was first used.- Parameters:
cutover- the cutover date, not null- Returns:
- a
HistoricChronology, never null
-
standardCutover
public static HistoricChronology standardCutover()
Obtains an instance ofHistoricChronologyusing the standard cutover date of 1582-10-15.- Returns:
- a
HistoricChronology, never null
-
checkNotNull
static void checkNotNull(java.lang.Object object, java.lang.String errorMessage)Validates that the input value is not null.- Parameters:
object- the object to checkerrorMessage- the error to throw- Throws:
java.lang.NullPointerException- if the object is null
-
getDayOfYear
int getDayOfYear(HistoricDate date)
Calculates the day-of-year from a date.- Parameters:
date- the date to use, not null- Returns:
- the day-of-year
-
getDateFromDayOfYear
HistoricDate getDateFromDayOfYear(int year, int dayOfYear)
Calculates the date from a year and day-of-year.- Parameters:
year- the year, validdayOfYear- the day-of-year, valid- Returns:
- the date, never null
-
isLeapYear
public boolean isLeapYear(int year)
Checks if the specified year is a leap year.A year is leap if the remainder after division by four equals three. This method does not validate the year passed in, and only has a well-defined result for years in the supported range.
- Parameters:
year- the year to check, not validated for range- Returns:
- true if the year is a leap year
-
getCutover
public LocalDate getCutover()
Gets the cutover date of the chronology.- Returns:
- the cutover date of the chronology, never null
-
getName
public java.lang.String getName()
Gets the name of the chronology.- Specified by:
getNamein classChronology- Returns:
- the name of the chronology, never null
-
eraRule
public DateTimeFieldRule<HistoricEra> eraRule()
Gets the rule for the year field in the Historic chronology.- Returns:
- the rule for the year field, never null
-
yearOfEraRule
public DateTimeFieldRule<java.lang.Integer> yearOfEraRule()
Gets the rule for the year field in the Historic chronology.- Returns:
- the rule for the year field, never null
-
yearRule
public DateTimeFieldRule<java.lang.Integer> yearRule()
Gets the rule for the year field in the Historic chronology.- Returns:
- the rule for the year field, never null
-
monthOfYearRule
public DateTimeFieldRule<MonthOfYear> monthOfYearRule()
Gets the rule for the month-of-year field in the Historic chronology.- Returns:
- the rule for the month-of-year field, never null
-
dayOfMonthRule
public DateTimeFieldRule<java.lang.Integer> dayOfMonthRule()
Gets the rule for the day-of-month field in the Historic chronology.- Returns:
- the rule for the day-of-month field, never null
-
dayOfYearRule
public DateTimeFieldRule<java.lang.Integer> dayOfYearRule()
Gets the rule for the day-of-year field in the Historic chronology.- Returns:
- the rule for the day-of-year field, never null
-
dayOfWeekRule
public DateTimeFieldRule<DayOfWeek> dayOfWeekRule()
Gets the rule for the day-of-week field in the Historic chronology.- Returns:
- the rule for the day-of-week field, never null
-
periodEras
public static PeriodUnit periodEras()
Gets the period unit for eras.The period unit defines the concept of a period of an era.
This is a basic unit and has no equivalent period. The estimated duration is equal to 2,000,000,000 years. This is equivalent to the ISO era period unit.
See
eraRule()for the main date-time field.- Returns:
- the period unit for years, never null
-
periodYears
public static PeriodUnit periodYears()
Gets the period unit for years.The period unit defines the concept of a period of a year. This has an estimated duration equal to 365.25 days.
See
yearRule()for the main date-time field.- Returns:
- the period unit for years, never null
-
periodMonths
public static PeriodUnit periodMonths()
Gets the period unit for months.The period unit defines the concept of a period of a month. Historic months are typically 30 days long, except for the 13th month which is 5 or 6 days long. The rule uses an estimated duration of 29.5 days.
See
monthOfYearRule()for the main date-time field.- Returns:
- the period unit for months, never null
-
periodWeeks
public static PeriodUnit periodWeeks()
Gets the period unit for weeks.The period unit defines the concept of a period of a week. This is equivalent to the ISO weeks period unit.
- Returns:
- the period unit for weeks, never null
-
periodDays
public static PeriodUnit periodDays()
Gets the period unit for days.The period unit defines the concept of a period of a day. This is equivalent to the ISO days period unit.
See
dayOfMonthRule()for the main date-time field.- Returns:
- the period unit for days, never null
-
-