The Japanese government defines the official name and start date of each era. Eras are consecutive and their date ranges do not overlap, so the end date of one era is always the day before the start date of the next era.
The Java SE Platform supports all eras defined by the Japanese government,
beginning with the Meiji era. Each era is identified in the Platform by an
integer value and a name. The of(int)
and valueOf(String)
methods may be used to obtain a singleton instance of JapaneseEra
for each era. The values()
method returns the singleton instances
of all supported eras.
For convenience, this class declares a number of public static final fields
that refer to singleton instances returned by the values()
method.
API Note
The fields declared in this class may evolve over time, in line with the
results of the values()
method. However, there is not necessarily
a 1:1 correspondence between the fields and the singleton instances.
API Note
The Japanese government may announce a new era and define its start date but not its official name. In this scenario, the singleton instance that represents the new era may return a name that is not stable until the official name is defined. Developers should exercise caution when relying on the name returned by any singleton instance that does not correspond to a public static final field.
Implementation Specification
This class is immutable and thread-safe.
Modifier and Type | Field and Description |
---|---|
pack-priv static final Era[] | |
pack-priv static final int | |
private final transient int | eraValue
The era value. |
public static final JapaneseEra | HEISEI
The singleton instance for the 'Heisei' era (1989-01-08 - 2019-04-30) which has the value 2. |
private static final JapaneseEra[] | |
public static final JapaneseEra | MEIJI
The singleton instance for the 'Meiji' era (1868-01-01 - 1912-07-29) which has the value -1. |
private static final int | |
public static final JapaneseEra | REIWA
The singleton instance for the 'Reiwa' era (2019-05-01 - ) which has the value 3. |
private static final long | serialVersionUID
Serialization version. |
public static final JapaneseEra | SHOWA
The singleton instance for the 'Showa' era (1926-12-25 - 1989-01-07) which has the value 1. |
private final transient LocalDate | |
public static final JapaneseEra | TAISHO
The singleton instance for the 'Taisho' era (1912-07-30 - 1926-12-24) which has the value 0. |
Access | Constructor and Description |
---|---|
private | JapaneseEra(int
the era value, validated eraValue, LocalDate the date representing the first date of the era, validated not null since)Creates an instance. |
Modifier and Type | Method and Description |
---|---|
pack-priv static JapaneseEra | |
pack-priv String | |
public String | getDisplayName(TextStyle
the style of the text required, not null style, Locale the locale to use, not null locale)Overrides default java. |
pack-priv String | |
pack-priv Era | Returns: the Sun private Era instance for thisJapaneseEra .Returns the Sun private Era instance corresponding to this |
public int | Returns: the era valueImplements java. int value.
|
public static JapaneseEra | Returns: theJapaneseEra singleton, not nullthe era to represent japaneseEra)Obtains an instance of |
private static int | Returns: the index of the current Erathe era value to convert to the index eraValue)Returns the index into the arrays from the Era value. |
pack-priv static Era | |
public ValueRange | Returns: the range of valid values for the field, not nullthe field to query the range for, not null field)Overrides default java. |
pack-priv static JapaneseEra | |
private void | |
pack-priv static JapaneseEra | |
public String | |
public static JapaneseEra | |
public static JapaneseEra[] | |
pack-priv void | |
private Object | Returns: the instance ofSer , not nullWrites the object using a dedicated serialized form. |
ERA_CONFIG | back to summary |
---|---|
pack-priv static final Era[] ERA_CONFIG |
ERA_OFFSET | back to summary |
---|---|
pack-priv static final int ERA_OFFSET |
eraValue | back to summary |
---|---|
private final transient int eraValue The era value. |
HEISEI | back to summary |
---|---|
public static final JapaneseEra HEISEI The singleton instance for the 'Heisei' era (1989-01-08 - 2019-04-30) which has the value 2. |
KNOWN_ERAS | back to summary |
---|---|
private static final JapaneseEra[] KNOWN_ERAS |
MEIJI | back to summary |
---|---|
public static final JapaneseEra MEIJI The singleton instance for the 'Meiji' era (1868-01-01 - 1912-07-29) which has the value -1. |
N_ERA_CONSTANTS | back to summary |
---|---|
private static final int N_ERA_CONSTANTS |
REIWA | back to summary |
---|---|
public static final JapaneseEra REIWA The singleton instance for the 'Reiwa' era (2019-05-01 - ) which has the value 3. The end date of this era is not specified, unless the Japanese Government defines it.
|
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Serialization version. |
SHOWA | back to summary |
---|---|
public static final JapaneseEra SHOWA The singleton instance for the 'Showa' era (1926-12-25 - 1989-01-07) which has the value 1. |
since | back to summary |
---|---|
private final transient LocalDate since |
TAISHO | back to summary |
---|---|
public static final JapaneseEra TAISHO The singleton instance for the 'Taisho' era (1912-07-30 - 1926-12-24) which has the value 0. |
JapaneseEra | back to summary |
---|---|
private JapaneseEra(int eraValue, LocalDate since) Creates an instance.
|
from | back to summary |
---|---|
pack-priv static JapaneseEra from(LocalDate date) Obtains an instance of
|
getAbbreviation | back to summary |
---|---|
pack-priv String getAbbreviation() |
getDisplayName | back to summary |
---|---|
public String getDisplayName(TextStyle style, Locale locale) Overrides default java. Doc from java. Gets the textual representation of this era. This returns the textual name used to identify the era, suitable for presentation to the user. The parameters control the style of the returned text and the locale.
If no textual mapping is found then the |
getName | back to summary |
---|---|
pack-priv String getName() |
getPrivateEra | back to summary |
---|---|
pack-priv Era getPrivateEra() Returns the Sun private Era instance corresponding to this
|
getValue | back to summary |
---|---|
public int getValue() Implements java. Gets the numeric era
The
|
of | back to summary |
---|---|
public static JapaneseEra of(int japaneseEra) Obtains an instance of
Every instance of
|
ordinal | back to summary |
---|---|
private static int ordinal(int eraValue) Returns the index into the arrays from the Era value. the eraValue is a valid Era number, -1..2.
|
privateEraFrom | back to summary |
---|---|
pack-priv static Era privateEraFrom(LocalDate isoDate) |
range | back to summary |
---|---|
public ValueRange range(TemporalField field) Overrides default java. Gets the range of valid values for the specified field. The range object expresses the minimum and maximum valid values for a field. This era is used to enhance the accuracy of the returned range. If it is not possible to return the range, because the field is not supported or for some other reason, an exception is thrown.
If the field is a
If the field is not a The range of valid Japanese eras can change over time due to the nature of the Japanese calendar system.
|
readExternal | back to summary |
---|---|
pack-priv static JapaneseEra readExternal(DataInput in) throws IOException |
readObject | back to summary |
---|---|
private void readObject(ObjectInputStream s) throws InvalidObjectException Defend against malicious streams.
|
toJapaneseEra | back to summary |
---|---|
pack-priv static JapaneseEra toJapaneseEra(Era privateEra) |
toString | back to summary |
---|---|
public String toString() Overrides java. Doc from java. Returns a string representation of the object. |
valueOf | back to summary |
---|---|
public static JapaneseEra valueOf(String japaneseEra) Returns the The string must match exactly the name of the era. (Extraneous whitespace characters are not permitted.)
Valid era names are the names of eras returned from
|
values | back to summary |
---|---|
public static JapaneseEra[] values() Returns an array of JapaneseEras. The array may contain eras defined by the Japanese government beyond the known era singletons. This method may be used to iterate over the JapaneseEras as follows: for (JapaneseEra c : JapaneseEra.values()) System.out.println(c);
|
writeExternal | back to summary |
---|---|
pack-priv void writeExternal(DataOutput out) throws IOException |
writeReplace | back to summary |
---|---|
private Object writeReplace() Writes the object using a dedicated serialized form. |