org.threeten.bp.chrono
Class JapaneseEra

java.lang.Object
  extended by org.threeten.bp.jdk8.DefaultInterfaceTemporalAccessor
      extended by org.threeten.bp.jdk8.DefaultInterfaceEra
          extended by org.threeten.bp.chrono.JapaneseEra
All Implemented Interfaces:
Serializable, Era, TemporalAccessor, TemporalAdjuster

public final class JapaneseEra
extends DefaultInterfaceEra
implements Serializable

An era in the Japanese Imperial calendar system.

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.

Specification for implementors

This class is immutable and thread-safe.

See Also:
Serialized Form

Field Summary
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.
 
Method Summary
 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.
 String toString()
           
static JapaneseEra valueOf(String japaneseEra)
          Returns the JapaneseEra with the name.
static JapaneseEra[] values()
          Returns an array of JapaneseEras.
 
Methods inherited from class org.threeten.bp.jdk8.DefaultInterfaceEra
adjustInto, get, getDisplayName, getLong, isSupported, query
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MEIJI

public static final JapaneseEra MEIJI
The singleton instance for the 'Meiji' era (1868-09-08 - 1912-07-29) which has the value -1.


TAISHO

public static final JapaneseEra TAISHO
The singleton instance for the 'Taisho' era (1912-07-30 - 1926-12-24) which has the value 0.


SHOWA

public static final JapaneseEra SHOWA
The singleton instance for the 'Showa' era (1926-12-25 - 1989-01-07) which has the value 1.


HEISEI

public static final JapaneseEra HEISEI
The singleton instance for the 'Heisei' era (1989-01-08 - current) which has the value 2.

Method Detail

of

public static JapaneseEra of(int japaneseEra)
Obtains an instance of 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.

Parameters:
japaneseEra - the era to represent
Returns:
the JapaneseEra singleton, not null
Throws:
DateTimeException - if the value is invalid

valueOf

public static JapaneseEra valueOf(String japaneseEra)
Returns the JapaneseEra with the name.

The string must match exactly the name of the era. (Extraneous whitespace characters are not permitted.)

Parameters:
japaneseEra - the japaneseEra name; non-null
Returns:
the JapaneseEra singleton, never null
Throws:
IllegalArgumentException - if there is not JapaneseEra with the specified name

values

public static JapaneseEra[] values()
Returns an array of JapaneseEras.

This method may be used to iterate over the JapaneseEras as follows:

 for (JapaneseEra c : JapaneseEra.values())
     System.out.println(c);
 

Returns:
an array of JapaneseEras

getValue

public int getValue()
Returns the numeric value of this JapaneseEra.

The SHOWA era that contains 1970-01-01 (ISO calendar system) has the value 1. Later eras are numbered from 2 (HEISEI). Earlier eras are numbered 0 (TAISHO) and -1 (MEIJI).

Specified by:
getValue in interface Era
Returns:
the era value

range

public ValueRange range(TemporalField field)
Description copied from interface: TemporalAccessor
Gets the range of valid values for the specified field.

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.

Specification for implementors

Implementations must check and handle all fields defined in 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.

Specified by:
range in interface TemporalAccessor
Overrides:
range in class DefaultInterfaceTemporalAccessor
Parameters:
field - the field to query the range for, not null
Returns:
the range of valid values for the field, not null

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007–2014 ThreeTen.org. All rights reserved.