@CalendarType(value="historic") public final class HistoricCalendar extends CalendarVariant<HistoricCalendar> implements LocalizedPatternSupport
Represents the historic christian calendar used in most European countries.
DAY_OF_WEEKDAY_OF_MONTHDAY_OF_YEARWEEKDAY_IN_MONTHMONTH_OF_YEARRELATED_STANDARD_YEARCENTURY_OF_ERAERAFurthermore, all elements defined in EpochDays and CommonElements are supported.
ChronoHistory history = ChronoHistory.of(Locale.UK);
ChronoFormatter<HistoricCalendar> f =
ChronoFormatter.ofStyle(DisplayMode.FULL, Locale.ENGLISH, HistoricCalendar.family()).with(history);
HistoricCalendar cal = HistoricCalendar.of(history, HistoricEra.AD, 1603, 3, 24);
String text = "Thursday, March 24, 1602/03 AD" // dual dating for the historic year
assertThat(f.format(cal), is(text));
assertThat(f.parse(text), is(cal));
Any gregorian date (ISO-8601) can be transformed to HistoricCalendar this simple way:
ChronoHistory history = ChronoHistory.ofFirstGregorianReform();
HistoricCalendar cal = PlainDate.of(1582, 10, 5).transform(HistoricCalendar.family(), history)
System.out.println(cal); // AD-1582-09-25[...], ten days were cut off by pope Gregor
Locale locale = Locale.forLanguageTag("de-DE-PREUSSEN-u-ca-historic");
ChronoFormatter<CalendarDate> f = ChronoFormatter.ofGenericCalendarStyle(DisplayMode.FULL, locale);
assertThat(
f.format(PlainDate.of(1610, 9, 1)),
is("Mittwoch, 22. August 1610 n. Chr."));
The key word is "historic". The ca-extension finally evaluates
ChronoHistory.of(Locale) for automatical conversions to
HistoricCalendar before formatting (as shown above).
| Modifier and Type | Field and Description |
|---|---|
static ChronoElement<Integer> |
CENTURY_OF_ERA
Represents the historic century.
|
static StdCalendarElement<Integer,HistoricCalendar> |
DAY_OF_MONTH
Represents the historic day of month.
|
static StdCalendarElement<Weekday,HistoricCalendar> |
DAY_OF_WEEK
Represents the historic day of week.
|
static StdCalendarElement<Integer,HistoricCalendar> |
DAY_OF_YEAR
Represents the historic day of year.
|
static ChronoElement<HistoricEra> |
ERA
Represents the historic era.
|
static StdCalendarElement<Month,HistoricCalendar> |
MONTH_OF_YEAR
Represents the historic month.
|
static TextElement<Integer> |
RELATED_STANDARD_YEAR
Represents the related standard year within current era which starts on first of January.
|
static OrdinalWeekdayElement<HistoricCalendar> |
WEEKDAY_IN_MONTH
Element with the ordinal day-of-week within given calendar month.
|
| Modifier and Type | Method and Description |
|---|---|
GeneralTimestamp<HistoricCalendar> |
at(PlainTime time)
Creates a new local timestamp with this date and given wall time.
|
GeneralTimestamp<HistoricCalendar> |
atTime(int hour,
int minute)
Is equivalent to
at(PlainTime.of(hour, minute)). |
boolean |
equals(Object obj)
Compares the whole state of this instance with given object.
|
static CalendarFamily<HistoricCalendar> |
family()
Returns the associated calendar family.
|
int |
getCentury()
Obtains the century of era.
|
int |
getDayOfMonth()
Yields the historic day of month.
|
Weekday |
getDayOfWeek()
Determines the day of week.
|
int |
getDayOfYear()
Yields the historic day of year.
|
static Weekmodel |
getDefaultWeekmodel()
Obtains the standard week model of this calendar.
|
HistoricEra |
getEra()
Yields the historic era.
|
ChronoHistory |
getHistory()
Obtains the underlying calendar history.
|
Month |
getMonth()
Yields the historic month.
|
String |
getVariant()
Yields the variant name of a calendar system.
|
int |
getYear()
Obtains the true historic year as displayed in historic documents.
|
int |
hashCode()
Subclasses must redefine this method corresponding to the
behaviour of
equals(). |
int |
lengthOfMonth()
Yields the length of current historic month in days.
|
int |
lengthOfYear()
Yields the length of current historic year in days.
|
HistoricCalendar |
nextDay()
Convenient short form for
with(DAY_OF_MONTH.incremented())
or plus(CalendarDays.ONE). |
static HistoricCalendar |
nowInSystemTime(ChronoHistory history)
Obtains the current historic calendar date in system time.
|
static HistoricCalendar |
of(ChronoHistory history,
HistoricEra era,
int relatedStandardYear,
int historicMonth,
int historicDayOfMonth)
Constructs a new historic calendar.
|
static HistoricCalendar |
of(ChronoHistory history,
HistoricEra era,
int yearOfEra,
YearDefinition yearDefinition,
int historicMonth,
int historicDayOfMonth)
Constructs a new historic calendar.
|
String |
toString()
Provides a complete textual representation of the state of this calendar variant.
|
HistoricCalendar |
withNewYear()
Obtains the start of this year (which is often not the first of January).
|
compareTo, getDaysSinceEpochUTC, isAfter, isBefore, isSimultaneous, minus, plus, withVariant, withVariantcontains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withgetFormatPattern, getFormatPattern, useDynamicFormatPatternfrom, from, from, transform, transform, transform, transform, transform, transformisAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqual@FormattableElement(format="G") public static final ChronoElement<HistoricEra> ERA
Represents the historic era.
The era value cannot be changed in any way which makes sense so this element is like a display-only element.
public static final ChronoElement<Integer> CENTURY_OF_ERA
Represents the historic century.
@FormattableElement(format="y") public static final TextElement<Integer> RELATED_STANDARD_YEAR
Represents the related standard year within current era which starts on first of January.
Note: Getting true historic years which take care of different new-year-rules
is possible via the expression getYear(). This year definition is similar to
CommonElements.RELATED_GREGORIAN_YEAR but takes into account the change
from julian to gregorian calendar.
When used in formatting of historic dates, Time4J will apply dual dating unless
a special year definition has been set as format attribute.
@FormattableElement(format="M", alt="L") public static final StdCalendarElement<Month,HistoricCalendar> MONTH_OF_YEAR
Represents the historic month.
The expression with(MONTH_OF_YEAR.incremented()) works in the following way:
Example (AD-1610-09-01 is invalid!):
ChronoHistory history = ChronoHistory.of(new Locale("de", "DE", "PREUSSEN"));
HistoricCalendar cal = HistoricCalendar.of(history, HistoricEra.AD, 1610, 8, 1);
System.out.println(cal.with(HistoricCalendar.MONTH_OF_YEAR.incremented()));
// AD-1610-09-02[...]
@FormattableElement(format="d") public static final StdCalendarElement<Integer,HistoricCalendar> DAY_OF_MONTH
Represents the historic day of month.
@FormattableElement(format="D") public static final StdCalendarElement<Integer,HistoricCalendar> DAY_OF_YEAR
Represents the historic day of year.
@FormattableElement(format="E") public static final StdCalendarElement<Weekday,HistoricCalendar> DAY_OF_WEEK
Represents the historic day of week.
If the day-of-week is set to a new value then Time4J handles the historic calendar week as starting on Sunday (usual in christian context).
@FormattableElement(format="F") public static final OrdinalWeekdayElement<HistoricCalendar> WEEKDAY_IN_MONTH
Element with the ordinal day-of-week within given calendar month.
public static HistoricCalendar of(ChronoHistory history, HistoricEra era, int relatedStandardYear, int historicMonth, int historicDayOfMonth)
Constructs a new historic calendar.
Equivalent to
of(ChronoHistory, HistoricEra, int, YearDefinition, int, int)
of(history, era, relatedStandardYear, historicMonth, historicDayOfMonth, YearDefinition.DUAL_DATING)}.
history - historization modelera - historic erarelatedStandardYear - the related standard year of era (>= 1) starting on January the firsthistoricMonth - historic month (1-12)historicDayOfMonth - historic day of month (1-31)IllegalArgumentException - if any argument is out of required maximum range or invalid for other reasonspublic static HistoricCalendar of(ChronoHistory history, HistoricEra era, int yearOfEra, YearDefinition yearDefinition, int historicMonth, int historicDayOfMonth)
Constructs a new historic calendar.
history - historization modelera - historic erayearOfEra - year of era which will be interpreted
according to given year definition (>= 1)yearDefinition - defines a strategy how to interprete year of erahistoricMonth - historic month (1-12)historicDayOfMonth - historic day of month (1-31)IllegalArgumentException - if any argument is out of required maximum range or invalid for other reasonspublic static HistoricCalendar nowInSystemTime(ChronoHistory history)
Obtains the current historic calendar date in system time.
Convenient short-cut for:
SystemClock.inLocalView().now(HistoricCalendar.family(), history, StartOfDay.MIDNIGHT).toDate()).
history - historization modelSystemClock.inLocalView()public ChronoHistory getHistory()
Obtains the underlying calendar history.
public HistoricEra getEra()
Yields the historic era.
public int getCentury()
Obtains the century of era.
public int getYear()
Obtains the true historic year as displayed in historic documents.
Important: The begin of a historic year can deviate from first of January.
Historic years are often not synchronized with month cycles. Users can apply the expression
getInt(RELATED_STANDARD_YEAR) in order to obtain the year beginning on first of January.
HistoricDate.getYearOfEra(NewYearStrategy),
ChronoHistory.getNewYearStrategy()public Month getMonth()
Yields the historic month.
public int getDayOfMonth()
Yields the historic day of month.
public Weekday getDayOfWeek()
Determines the day of week.
The week model has never been subject to historical changes leaving aside radical calendar reforms like the Frenh revolutionary calendar.
public int getDayOfYear()
Yields the historic day of year.
public String getVariant()
VariantSourceYields the variant name of a calendar system.
getVariant in interface VariantSourcepublic int lengthOfMonth()
Yields the length of current historic month in days.
-1 if the length cannot be determinedpublic int lengthOfYear()
Yields the length of current historic year in days.
-1 if the length cannot be determinedpublic HistoricCalendar withNewYear()
Obtains the start of this year (which is often not the first of January).
public HistoricCalendar nextDay()
Convenient short form for with(DAY_OF_MONTH.incremented())
or plus(CalendarDays.ONE).
CalendarVariant.plus(CalendarDays),
CalendarDays.ONEpublic GeneralTimestamp<HistoricCalendar> at(PlainTime time)
Creates a new local timestamp with this date and given wall time.
If the time T24:00 is used
then the resulting timestamp will automatically be normalized such
that the timestamp will contain the following day instead.
time - wall timepublic GeneralTimestamp<HistoricCalendar> atTime(int hour, int minute)
Is equivalent to at(PlainTime.of(hour, minute)).
hour - hour of day in range (0-24)minute - minute of hour in range (0-59)IllegalArgumentException - if any argument is out of rangepublic boolean equals(Object obj)
CalendarVariantCompares the whole state of this instance with given object.
Implementations will usually define their state based on the temporal position and the variant name. Exceptions from this rule should be explicitly documented and reasoned.
equals in class CalendarVariant<HistoricCalendar>CalendarVariant.compareTo(CalendarVariant)public int hashCode()
CalendarVariantSubclasses must redefine this method corresponding to the
behaviour of equals().
hashCode in class CalendarVariant<HistoricCalendar>public String toString()
CalendarVariantProvides a complete textual representation of the state of this calendar variant.
toString in class CalendarVariant<HistoricCalendar>public static Weekmodel getDefaultWeekmodel()
Obtains the standard week model of this calendar.
Christian calendars usually starts on Sunday.
public static CalendarFamily<HistoricCalendar> family()
Returns the associated calendar family.
Copyright © 2014–2021. All rights reserved.