java.io.Serializable, Era, TemporalAccessor, TemporalAdjusterpublic final class JapaneseEra extends DefaultInterfaceEra implements java.io.Serializable
This class defines the valid eras for the Japanese chronology. Japan introduced the Gregorian calendar starting with Meiji 6. Only Meiji and later eras are supported; dates before Meiji 6, January 1 are not supported.
The four supported eras are hard-coded.
A single additional era may be registered using registerEra(LocalDate, String).
| Modifier and Type | Field | Description |
|---|---|---|
static JapaneseEra |
HEISEI |
The singleton instance for the 'Heisei' era (1989-01-08 - current)
which has the value 2.
|
static JapaneseEra |
MEIJI |
The singleton instance for the 'Meiji' era (1868-09-08 - 1912-07-29)
which has the value -1.
|
static JapaneseEra |
SHOWA |
The singleton instance for the 'Showa' era (1926-12-25 - 1989-01-07)
which has the value 1.
|
static JapaneseEra |
TAISHO |
The singleton instance for the 'Taisho' era (1912-07-30 - 1926-12-24)
which has the value 0.
|
| Modifier and Type | Method | Description |
|---|---|---|
int |
getValue() |
Returns the numeric value of this
JapaneseEra. |
static JapaneseEra |
of(int japaneseEra) |
Obtains an instance of
JapaneseEra from an int value. |
ValueRange |
range(TemporalField field) |
Gets the range of valid values for the specified field.
|
static JapaneseEra |
registerEra(LocalDate since,
java.lang.String name) |
Registers an additional instance of
JapaneseEra. |
java.lang.String |
toString() |
|
static JapaneseEra |
valueOf(java.lang.String japaneseEra) |
Returns the
JapaneseEra with the name. |
static JapaneseEra[] |
values() |
Returns an array of JapaneseEras.
|
adjustInto, get, getDisplayName, getLong, isSupported, querypublic static final JapaneseEra MEIJI
public static final JapaneseEra TAISHO
public static final JapaneseEra SHOWA
public static final JapaneseEra HEISEI
public static JapaneseEra registerEra(LocalDate since, java.lang.String name)
JapaneseEra.
A new Japanese era can begin at any time. This method allows one new era to be registered without the need for a new library version. If needed, callers should assign the result to a static variable accessible across the application. This must be done once, in early startup code.
NOTE: This method does not exist in Java SE 8.
since - the date representing the first date of the era, validated not nullname - the nameJapaneseEra singleton, not nullDateTimeException - if an additional era has already been registeredpublic static JapaneseEra of(int japaneseEra)
JapaneseEra from an int value.
The SHOWA era that contains 1970-01-01 (ISO calendar system) has the value 1
Later era is numbered 2 (HEISEI). Earlier eras are numbered 0 (TAISHO),
-1 (MEIJI), only Meiji and later eras are supported.
japaneseEra - the era to representJapaneseEra singleton, not nullDateTimeException - if the value is invalidpublic static JapaneseEra valueOf(java.lang.String japaneseEra)
JapaneseEra with the name.
The string must match exactly the name of the era. (Extraneous whitespace characters are not permitted.)
japaneseEra - the japaneseEra name; non-nullJapaneseEra singleton, never nulljava.lang.IllegalArgumentException - if there is not JapaneseEra with the specified namepublic static JapaneseEra[] values()
This method may be used to iterate over the JapaneseEras as follows:
for (JapaneseEra c : JapaneseEra.values())
System.out.println(c);
public int getValue()
public ValueRange range(TemporalField field)
TemporalAccessor
All fields can be expressed as a long integer.
This method returns an object that describes the valid range for that value.
The value of this temporal object is used to enhance the accuracy of the returned range.
If the date-time cannot return the range, because the field is unsupported or for
some other reason, an exception will be thrown.
Note that the result only describes the minimum and maximum valid values and it is important not to read too much into them. For example, there could be values within the range that are invalid for the field.
ChronoField.
If the field is supported, then the range of the field must be returned.
If unsupported, then a DateTimeException must be thrown.
If the field is not a ChronoField, then the result of this method
is obtained by invoking TemporalField.rangeRefinedBy(TemporalAccessorl)
passing this as the argument.
Implementations must not alter either this object.
range in interface TemporalAccessorrange in class DefaultInterfaceTemporalAccessorfield - the field to query the range for, not nullpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2007–2018 ThreeTen.org. All rights reserved.