Enum Class HistoricEra
- All Implemented Interfaces:
Serializable
,Comparable<HistoricEra>
,Constable
,Calendrical
HistoricEra
is an enum representing the historic era concepts of BCE and CE.
BCE is defined as the time-line before historic year 1, while CE is defined as
the time-line from year 1 onwards.
The calendrical framework requires date-time fields to have an int
value.
The int
value follows Calendar
, assigning 0 to BCE and 1 to CE.
It is recommended that applications use the enum rather than the int
value
to ensure code clarity.
Do not use ordinal()
to obtain the numeric representation of HistoricEra
.
Use getValue()
instead.
HistoricEra is an immutable and thread-safe enum.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
get
(CalendricalRule<T> rule) Gets the value of the specified calendrical rule.getShortText
(Locale locale) Gets the short textual representation of this BCE/CE, such as 'BCE' or 'CE'.Gets the short textual representation of this day-of-week, such as 'BCE' or 'CE'.int
getValue()
Gets the BCE/CEint
value.static HistoricEra
of
(int era) Obtains an instance ofHistoricEra
from anint
value.static HistoricEra
Returns the enum constant of this class with the specified name.static HistoricEra[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
BCE
The singleton instance for the era BCE - Before Common Era. This has the numeric value of0
. -
CE
The singleton instance for the era CE - Common Era. This has the numeric value of1
.
-
-
Constructor Details
-
HistoricEra
private HistoricEra()
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
of
Obtains an instance ofHistoricEra
from anint
value.HistoricEra
is an enum representing the historic eras of BCE/CE. This factory allows the enum to be obtained from theint
value. Theint
value followsCalendar
, assigning 0 to BCE and 1 to CE.An exception is thrown if the value is invalid. The exception uses the
ISOChronology
BCE/CE rule to indicate the failed rule.- Parameters:
era
- the BCE/CE value to represent, from 0 (BCE) to 1 (CE)- Returns:
- the HistoricEra singleton, never null
- Throws:
IllegalCalendarFieldValueException
- if the value is invalid
-
getValue
public int getValue()Gets the BCE/CEint
value.The values are numbered following
Calendar
, assigning 0 to BCE and 1 to CE.- Returns:
- the BCE/CE value, from 0 (BCE) to 1 (CE)
-
get
Gets the value of the specified calendrical rule.This returns the one of the era values if the type of the rule is
HistoricEra
. Other rules will returnnull
.- Specified by:
get
in interfaceCalendrical
- Parameters:
rule
- the rule to use, not null- Returns:
- the value for the rule, null if the value cannot be returned
-
getShortText
Gets the short textual representation of this BCE/CE, such as 'BCE' or 'CE'.If there is no textual mapping for the locale, then the value is returned as per
Integer.toString()
.- Parameters:
locale
- the locale to use, not null- Returns:
- the short text value of the BCE/CE, never null
-
getText
Gets the short textual representation of this day-of-week, such as 'BCE' or 'CE'.If there is no textual mapping for the locale, then the value is returned as per
Integer.toString()
.- Parameters:
locale
- the locale to use, not null- Returns:
- the long text value of the BCE/CE, never null
-