public enum HistoricEra extends Enum<HistoricEra> implements 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.
| Enum Constant and Description |
|---|
BCE
The singleton instance for the era BCE - Before Common Era.
|
CE
The singleton instance for the era CE - Common Era.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
get(CalendricalRule<T> rule)
Gets the value of the specified calendrical rule.
|
String |
getShortText(Locale locale)
Gets the short textual representation of this BCE/CE, such as 'BCE' or 'CE'.
|
String |
getText(Locale locale)
Gets the short textual representation of this day-of-week, such as 'BCE' or 'CE'.
|
int |
getValue()
Gets the BCE/CE
int value. |
static HistoricEra |
of(int era)
Obtains an instance of
HistoricEra from an int value. |
static HistoricEra |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static HistoricEra[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final HistoricEra BCE
0.public static final HistoricEra CE
1.public static HistoricEra[] values()
for (HistoricEra c : HistoricEra.values()) System.out.println(c);
public static HistoricEra valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static HistoricEra of(int era)
HistoricEra from an int value.
HistoricEra is an enum representing the historic eras of BCE/CE.
This factory allows the enum to be obtained from the int value.
The int value follows Calendar, 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.
era - the BCE/CE value to represent, from 0 (BCE) to 1 (CE)IllegalCalendarFieldValueException - if the value is invalidpublic int getValue()
int value.
The values are numbered following Calendar, assigning 0 to BCE and 1 to CE.
public <T> T get(CalendricalRule<T> rule)
This returns the one of the era values if the type of the rule
is HistoricEra. Other rules will return null.
get in interface Calendricalrule - the rule to use, not nullpublic String getShortText(Locale locale)
If there is no textual mapping for the locale, then the value is
returned as per Integer.toString().
locale - the locale to use, not nullpublic String getText(Locale locale)
If there is no textual mapping for the locale, then the value is
returned as per Integer.toString().
locale - the locale to use, not nullCopyright © 2024. All rights reserved.