Class ChronoHistory
- All Implemented Interfaces:
Serializable
,VariantSource
Represents the chronological history of calendar reforms in a given region.
All non-proleptic history objects are limited to the range BC 45 until the year AD 9999.
- Since:
- 3.0
- Author:
- Meno Hochschild
- See Also:
- Serialized Form
-
Field Summary
Modifier and TypeFieldDescriptionstatic ChronoHistory
Describes no real historic event but just the proleptic byzantine calendar which is assumed to be in power all times from the creation of the world until the byzantine year 999984973.static ChronoHistory
Describes no real historic event but just the proleptic gregorian calendar which is assumed to be in power all times.static ChronoHistory
Describes no real historic event but just the proleptic julian calendar which is assumed to be in power all times (with the technical constraintBC 999979466 - AD 999979465
).static AttributeKey<YearDefinition>
Format attribute controlling the type of historic year used in parsing or formatting. -
Method Summary
Modifier and TypeMethodDescriptionDefines the element for the century of a year in a given historic era.convert(HistoricDate date)
Converts given historic date to an ISO-8601-date.Converts given ISO-8601-date to a historic date.date()
Defines the element for the historic date.Defines the element for the historic day of month.Defines the element for the historic day of year.boolean
era()
Defines the element for the historic era.static ChronoHistory
Reconstructs the calendar history from given variant description.Yields the historic julian leap year pattern if available.getBeginOfYear(HistoricEra era, int yearOfEra)
Determines the date of New Year.Set<ChronoElement<?>>
Yields all associated elements.Yields the date of final introduction of gregorian calendar.int
getLengthOfYear(HistoricEra era, int yearOfEra)
Determines the length of given historic year in days.Yields the new-year-strategy.Yields the variant of a historic calendar.boolean
Determines if this history has defined any historic julian leap year sequence.boolean
Determines if this history has at least one gregorian calendar reform date.int
hashCode()
boolean
isValid(HistoricDate date)
Is given historic date valid?month()
Defines the element for the historic month.static ChronoHistory
Determines the (usually approximate) history of gregorian calendar reforms for given locale.static ChronoHistory
Describes the original switch from julian to gregorian calendar introduced by pope Gregor on 1582-10-15.static ChronoHistory
ofGregorianReform(PlainDate start)
Describes a single switch from julian to gregorian calendar at given date.static ChronoHistory
ofSweden()
The Swedish calendar has three cutover dates due to a failed experiment when switching to gregorian calendar in the years 1700-1712 step by step.toString()
with(AncientJulianLeapYears ancientJulianLeapYears)
Creates a copy of this history with given historic julian leap year sequence.with(EraPreference eraPreference)
Creates a copy of this history with given era preference.with(NewYearStrategy newYearStrategy)
Creates a copy of this history with given new-year-strategy.Defines the element for the year of a given historic era.yearOfEra(YearDefinition yearDefinition)
Defines the element for the year of a given historic era.
-
Field Details
-
YEAR_DEFINITION
Format attribute controlling the type of historic year used in parsing or formatting.- Since:
- 3.18/4.14
-
PROLEPTIC_GREGORIAN
Describes no real historic event but just the proleptic gregorian calendar which is assumed to be in power all times.
This constant rather serves for academic purposes. Users will normally use
PlainDate
without an era. -
PROLEPTIC_JULIAN
Describes no real historic event but just the proleptic julian calendar which is assumed to be in power all times (with the technical constraint
BC 999979466 - AD 999979465
).This constant rather serves for academic purposes because the julian calendar is now nowhere in power and has not existed before the calendar reform of Julius Caesar.
-
PROLEPTIC_BYZANTINE
Describes no real historic event but just the proleptic byzantine calendar which is assumed to be in power all times from the creation of the world until the byzantine year 999984973.
This constant rather serves for academic purposes because the byzantine calendar was in latest use in Russia before 1700.
- Since:
- 3.14/4.11
- See Also:
HistoricEra.BYZANTINE
-
-
Method Details
-
ofFirstGregorianReform
Describes the original switch from julian to gregorian calendar introduced by pope Gregor on 1582-10-15.
- Returns:
- chronological history with cutover to gregorian calendar on 1582-10-15
- Since:
- 3.0
- See Also:
ofGregorianReform(PlainDate)
-
ofGregorianReform
Describes a single switch from julian to gregorian calendar at given date.
Since version 3.1 there are two special cases to consider. If the given date is the maximum/minimum of the date axis then this method will return the proleptic julian/gregorian
ChronoHistory
.- Parameters:
start
- calendar date when the gregorian calendar was introduced- Returns:
- new chronological history with only one cutover from julian to gregorian calendar
- Throws:
IllegalArgumentException
- if given date is before first introduction of gregorian calendar on 1582-10-15- Since:
- 3.0
- See Also:
ofFirstGregorianReform()
-
of
Determines the (usually approximate) history of gregorian calendar reforms for given locale.
The actual implementation just falls back to the introduction of gregorian calendar by pope Gregor if a locale is not explicitly mentioned in following table. Later releases of Time4J might refine the implementation for most European countries. In any case, this method does not reflect the absolute historic truth. Various regions in many countries used different rules than the rest. And sometimes historic sources and literature are simply unreliable so this method is just an approach on base of best efforts. In case of doubt, users should prefer to model the concrete history themselves as needed. For any cutover date not supported by this method, users can instead call
ofGregorianReform(PlainDate)
.This method does not use the language part of given locale but the country part (ISO-3166), in case of Scotland also the variant part (SCT), in case of Germany the variant part (PREUSSEN or PROTESTANT etc.). In order to create an appropriate locale, use a constructor like
new Locale("en", "GB", "SCT")
.Summary Region Locale Gregorian cutover New Year (using estimates) Era preference Italy IT 1582-10-15 CHRISTMAS_STYLE.until(1583) Florence IT-FLORENCE 1582-10-15 MARIA_ANUNCIATA.until(1749) Pisa IT-PISA 1582-10-15 CALCULUS_PISANUS.until(1749) Republic of Venice IT-VENICE 1582-10-15 BEGIN_OF_MARCH.until(1798) Spain ES 1582-10-15 BEGIN_OF_JANUARY.until(1383)
.and(CHRISTMAS_STYLE.until(1556))HISPANIC (until 1383) Portugal PT 1582-10-15 BEGIN_OF_JANUARY.until(1422)
.and(CHRISTMAS_STYLE.until(1556))HISPANIC (until 1422) Poland PL 1582-10-15 France FR 1582-12-20 EASTER_STYLE.until(1567) Holland NL 1583-01-01 Holy Roman Empire 1) DE 1582-10-15 CHRISTMAS_STYLE.until(1544) Bavaria DE-BAYERN 1583-10-16 CHRISTMAS_STYLE.until(1544) Prussia DE-PREUSSEN 1610-09-02 CHRISTMAS_STYLE.until(1559) Germany (protestant) DE-PROTESTANT 1700-03-01 CHRISTMAS_STYLE.until(1559) Austria AT 1584-01-17 Switzerland CH 1584-01-22 Hungaria HU 1587-11-01 Danmark DK 1700-03-01 MARIA_ANUNCIATA.until(1623) Norway NO 1700-03-01 MARIA_ANUNCIATA.until(1623) England GB 1752-09-14 CHRISTMAS_STYLE.until(1087)
.and(BEGIN_OF_JANUARY.until(1155))
.and(MARIA_ANUNCIATA.until(1752))Scotland GB-SCT 1752-09-14 CHRISTMAS_STYLE.until(1087)
.and(BEGIN_OF_JANUARY.until(1155))
.and(MARIA_ANUNCIATA.until(1600))Sweden 2) SE 1753-03-01 Russia 3) RU 1918-02-14 BEGIN_OF_JANUARY.until(988)
.and(BEGIN_OF_MARCH.until(1493))
.and(BEGIN_OF_SEPTEMBER.until(1700))BYZANTINE (988-1700) 1) Fallback for catholic regions in German countries, but most regions started Gregorian calendar later.
2) Sweden used a special calendar shifted by one day between 1700 and 1712 (supported by Time4J).
3) Special case for Byzantine year 7208: It lasted from AD-1699-09-01 until AD-1699-12-31 (Julian calendar).- Parameters:
locale
- country setting- Returns:
- localized chronological history
- Since:
- 3.0
- See Also:
ofGregorianReform(PlainDate)
-
ofSweden
The Swedish calendar has three cutover dates due to a failed experiment when switching to gregorian calendar in the years 1700-1712 step by step.
- Returns:
- swedish chronological history
- Since:
- 3.0
-
isValid
Is given historic date valid?
If the argument is
null
then this method returnsfalse
.- Parameters:
date
- historic calendar date to be checked, maybenull
- Returns:
false
if given date is invalid elsetrue
- Since:
- 3.0
-
convert
Converts given historic date to an ISO-8601-date.
- Parameters:
date
- historic calendar date- Returns:
- ISO-8601-date (gregorian)
- Throws:
IllegalArgumentException
- if given date is invalid or out of supported range- Since:
- 3.0
- See Also:
isValid(HistoricDate)
-
convert
Converts given ISO-8601-date to a historic date.
- Parameters:
date
- ISO-8601-date (gregorian)- Returns:
- historic calendar date
- Throws:
IllegalArgumentException
- if given date is out of supported range- Since:
- 3.0
-
from
Reconstructs the calendar history from given variant description.
- Parameters:
variant
- description as defined ingetVariant()
- Returns:
- ChronoHistory
- Throws:
IllegalArgumentException
- if the variant cannot be interpreted as calendar history- Since:
- 3.36/4.31
-
getVariant
Yields the variant of a historic calendar.
- Specified by:
getVariant
in interfaceVariantSource
- Returns:
- text describing the internal state
- Since:
- 3.11/4.8
- See Also:
from(String)
-
getGregorianCutOverDate
Yields the date of final introduction of gregorian calendar.
- Returns:
- ISO-8601-date (gregorian)
- Throws:
UnsupportedOperationException
- if this history is proleptic- Since:
- 3.0
- See Also:
hasGregorianCutOverDate()
-
hasGregorianCutOverDate
public boolean hasGregorianCutOverDate()Determines if this history has at least one gregorian calendar reform date.
- Returns:
- boolean
- Since:
- 3.11/4.8
- See Also:
getGregorianCutOverDate()
-
getBeginOfYear
Determines the date of New Year.
Side note: This method should usually yield a valid historic date unless in case of ill configured new-year-strategies which don't play well with configured cutover-dates.
- Parameters:
era
- historic erayearOfEra
- historic year of era as displayed (deviating from standard calendar year)- Returns:
- historic date of New Year
- Throws:
IllegalArgumentException
- if given year is out of range or such that the result becomes invalid- Since:
- 3.14/4.11
- See Also:
NewYearRule
,getLengthOfYear(HistoricEra, int)
,with(NewYearStrategy)
,isValid(HistoricDate)
,HistoricDate.getYearOfEra(NewYearStrategy)
-
getLengthOfYear
Determines the length of given historic year in days.
The length of year can be affected by cutover gaps, different leap year rules and new year strategies.
- Parameters:
era
- historic erayearOfEra
- historic year of era as displayed (deviating from standard calendar year)- Returns:
- length of historic year in days or
-1
if the length cannot be determined - Since:
- 3.0
- See Also:
getBeginOfYear(HistoricEra, int)
,getGregorianCutOverDate()
,with(NewYearStrategy)
,with(AncientJulianLeapYears)
,HistoricDate.getYearOfEra(NewYearStrategy)
-
getAncientJulianLeapYears
Yields the historic julian leap year pattern if available.
- Returns:
- sequence of historic julian leap years
- Throws:
UnsupportedOperationException
- if this history has not defined any historic julian leap years- Since:
- 3.11/4.8
- See Also:
hasAncientJulianLeapYears()
,with(AncientJulianLeapYears)
-
hasAncientJulianLeapYears
public boolean hasAncientJulianLeapYears()Determines if this history has defined any historic julian leap year sequence.
- Returns:
- boolean
- Since:
- 3.11/4.8
- See Also:
with(AncientJulianLeapYears)
,getAncientJulianLeapYears()
-
with
Creates a copy of this history with given historic julian leap year sequence.
This method has no effect if applied on
ChronoHistory.PROLEPTIC_GREGORIAN
orChronoHistory.PROLEPTIC_JULIAN
orChronoHistory.PROLEPTIC_BYZANTINE
.- Parameters:
ancientJulianLeapYears
- sequence of historic julian leap years- Returns:
- new history which starts at first of January in year BC 45
- Since:
- 3.11/4.8
-
getNewYearStrategy
Yields the new-year-strategy.
If not specified then this method falls back to first of January.
- Returns:
- NewYearStrategy
- Since:
- 3.14/4.11
- See Also:
with(NewYearStrategy)
-
with
Creates a copy of this history with given new-year-strategy.
This method has no effect if applied on
ChronoHistory.PROLEPTIC_GREGORIAN
orChronoHistory.PROLEPTIC_JULIAN
orChronoHistory.PROLEPTIC_BYZANTINE
.- Parameters:
newYearStrategy
- strategy how to determine New Year- Returns:
- new history with changed new-year-strategy
- Since:
- 3.14/4.11
- See Also:
getBeginOfYear(HistoricEra, int)
,getLengthOfYear(HistoricEra, int)
,getNewYearStrategy()
-
with
Creates a copy of this history with given era preference.
This method has no effect if applied on
ChronoHistory.PROLEPTIC_GREGORIAN
orChronoHistory.PROLEPTIC_JULIAN
orChronoHistory.PROLEPTIC_BYZANTINE
.Background: Some historic calendars used different eras than AD or BC. For example, Russia used the Byzantine calendar before Julian year 1700 using the era Anno Mundi. This can be expressed by setting a suitable era preference.
- Parameters:
eraPreference
- strategy which era should be preferred (most relevant for printing)- Returns:
- new history with changed era preference
- Since:
- 3.14/4.11
-
date
Defines the element for the historic date.
This element is applicable on all chronological types which have registered the element
PlainDate.COMPONENT
.- Returns:
- date-related element
- Since:
- 3.15/4.12
- See Also:
PlainDate
,PlainTimestamp
-
era
Defines the element for the historic era.
This element is applicable on all chronological types which have registered the element
PlainDate.COMPONENT
. The era value cannot be changed in any way which makes sense so this element is like a display-only element.- Returns:
- era-related element
- Since:
- 3.0
- See Also:
PlainDate
,PlainTimestamp
-
yearOfEra
Defines the element for the year of a given historic era.
This element is applicable on all chronological types which have registered the element
PlainDate.COMPONENT
. The year starts on first of January. Note: Getting true historic years which take care of different new-year-rules is possible via the expressionplainDate.get(history.date()).getYearOfEra(history.getNewYearStrategy())
.- Returns:
- year-of-era-related element
- Since:
- 3.0
- See Also:
PlainDate
,PlainTimestamp
,yearOfEra(YearDefinition)
-
yearOfEra
Defines the element for the year of a given historic era.
This element is applicable on all chronological types which have registered the element
PlainDate.COMPONENT
.Example: Many parts of France used Easter style for New Year so the year 1564 began on 1564-04-01 and ended on 1565-04-21 causing an ambivalency for April dates. Setting the date to April 10th in historic year 1564 can be expressed in a non-ambivalent way if a suitable year definition is applied (standard calendar years 1564 or 1565 possible).
ChronoHistory history = ChronoHistory.of(Locale.FRANCE); PlainDate date = history.convert(HistoricDate.of(HistoricEra.AD, 1563, 4, 10)); assertThat( date.with(history.yearOfEra(YearDefinition.AFTER_NEW_YEAR), 1564), is(history.convert(HistoricDate.of(HistoricEra.AD, 1564, 4, 10)))); assertThat( date.with(history.yearOfEra(YearDefinition.BEFORE_NEW_YEAR), 1564), is(history.convert(HistoricDate.of(HistoricEra.AD, 1565, 4, 10))));
- Parameters:
yearDefinition
- determines how to display or interprete a historic year- Returns:
- year-of-era-related element
- Since:
- 3.19/4.15
- See Also:
PlainDate
,PlainTimestamp
-
centuryOfEra
Defines the element for the century of a year in a given historic era.
This element is applicable on all chronological types which have registered the element
PlainDate.COMPONENT
. The underlying year starts on first of January. As example, the 20th century lasted from year 1901 to year 2000.- Returns:
- century-of-era-related element
- Since:
- 3.23/4.19
- See Also:
PlainDate
,PlainTimestamp
,yearOfEra()
-
month
Defines the element for the historic month.
This element is applicable on all chronological types which have registered the element
PlainDate.COMPONENT
.- Returns:
- month-related element
- Since:
- 3.0
- See Also:
PlainDate
,PlainTimestamp
-
dayOfMonth
Defines the element for the historic day of month.
This element is applicable on all chronological types which have registered the element
PlainDate.COMPONENT
.- Returns:
- day-of-month-related element
- Since:
- 3.0
- See Also:
PlainDate
,PlainTimestamp
-
dayOfYear
Defines the element for the historic day of year.
This element is applicable on all chronological types which have registered the element
PlainDate.COMPONENT
. Note: An eventually deviating new-year-strategy will be taken into account so this element follows the year cycle which is decoupled from the month cycle.- Returns:
- day-of-year-related element
- Since:
- 3.16/4.13
- See Also:
PlainDate
,PlainTimestamp
-
getElements
Yields all associated elements.
- Returns:
- unmodifiable set of historic elements
- Since:
- 3.1
-
equals
-
hashCode
public int hashCode() -
toString
-