Enum HistoricEra
- java.lang.Object
-
- java.lang.Enum<HistoricEra>
-
- javax.time.i18n.HistoricEra
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<HistoricEra>,Calendrical
public enum HistoricEra extends java.lang.Enum<HistoricEra> implements Calendrical
An era in the historic calendar system, with the values 'BCE' and 'CE'.HistoricErais 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
intvalue. Theintvalue followsCalendar, assigning 0 to BCE and 1 to CE. It is recommended that applications use the enum rather than theintvalue to ensure code clarity.Do not use
ordinal()to obtain the numeric representation ofHistoricEra. UsegetValue()instead.HistoricEra is an immutable and thread-safe enum.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateHistoricEra()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tget(CalendricalRule<T> rule)Gets the value of the specified calendrical rule.java.lang.StringgetShortText(java.util.Locale locale)Gets the short textual representation of this BCE/CE, such as 'BCE' or 'CE'.java.lang.StringgetText(java.util.Locale locale)Gets the short textual representation of this day-of-week, such as 'BCE' or 'CE'.intgetValue()Gets the BCE/CEintvalue.static HistoricEraof(int era)Obtains an instance ofHistoricErafrom anintvalue.static HistoricEravalueOf(java.lang.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.
-
-
-
Enum Constant Detail
-
BCE
public static final HistoricEra BCE
The singleton instance for the era BCE - Before Common Era. This has the numeric value of0.
-
CE
public static final HistoricEra CE
The singleton instance for the era CE - Common Era. This has the numeric value of1.
-
-
Method Detail
-
values
public static HistoricEra[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (HistoricEra c : HistoricEra.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static HistoricEra valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
of
public static HistoricEra of(int era)
Obtains an instance ofHistoricErafrom anintvalue.HistoricErais an enum representing the historic eras of BCE/CE. This factory allows the enum to be obtained from theintvalue. Theintvalue followsCalendar, assigning 0 to BCE and 1 to CE.An exception is thrown if the value is invalid. The exception uses the
ISOChronologyBCE/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/CEintvalue.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
public <T> T get(CalendricalRule<T> rule)
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:
getin interfaceCalendrical- Parameters:
rule- the rule to use, not null- Returns:
- the value for the rule, null if the value cannot be returned
-
getShortText
public java.lang.String getShortText(java.util.Locale locale)
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
public java.lang.String getText(java.util.Locale locale)
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
-
-