Enum MinguoEra
- java.lang.Object
-
- java.lang.Enum<MinguoEra>
-
- org.threeten.bp.chrono.MinguoEra
-
- All Implemented Interfaces:
Serializable
,Comparable<MinguoEra>
,Era
,TemporalAccessor
,TemporalAdjuster
public enum MinguoEra extends Enum<MinguoEra> implements Era
An era in the Minguo calendar system.The Minguo calendar system has two eras. The date
0001-01-01 (Minguo)
is equal to1912-01-01 (ISO)
.Do not use
ordinal()
to obtain the numeric representation ofMinguoEra
. UsegetValue()
instead.Specification for implementors
This is an immutable and thread-safe enum.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BEFORE_ROC
The singleton instance for the era BEFORE_ROC, 'Before Republic of China'.ROC
The singleton instance for the era ROC, 'Republic of China'.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Temporal
adjustInto(Temporal temporal)
Adjusts the specified temporal object.int
get(TemporalField field)
Gets the value of the specified field as anint
.String
getDisplayName(TextStyle style, Locale locale)
Gets the textual representation of this era.long
getLong(TemporalField field)
Gets the value of the specified field as along
.int
getValue()
Gets the numeric eraint
value.boolean
isSupported(TemporalField field)
Checks if the specified field is supported.static MinguoEra
of(int era)
Obtains an instance ofMinguoEra
from anint
value.<R> R
query(TemporalQuery<R> query)
Queries this date-time.ValueRange
range(TemporalField field)
Gets the range of valid values for the specified field.static MinguoEra
valueOf(String name)
Returns the enum constant of this type with the specified name.static MinguoEra[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
BEFORE_ROC
public static final MinguoEra BEFORE_ROC
The singleton instance for the era BEFORE_ROC, 'Before Republic of China'. This has the numeric value of0
.
-
ROC
public static final MinguoEra ROC
The singleton instance for the era ROC, 'Republic of China'. This has the numeric value of1
.
-
-
Method Detail
-
values
public static MinguoEra[] 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 (MinguoEra c : MinguoEra.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MinguoEra valueOf(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:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
of
public static MinguoEra of(int era)
Obtains an instance ofMinguoEra
from anint
value.MinguoEra
is an enum representing the Minguo eras of BEFORE_ROC/ROC. This factory allows the enum to be obtained from theint
value.- Parameters:
era
- the BEFORE_ROC/ROC value to represent, from 0 (BEFORE_ROC) to 1 (ROC)- Returns:
- the era singleton, not null
- Throws:
DateTimeException
- if the value is invalid
-
getValue
public int getValue()
Gets the numeric eraint
value.The era BEFORE_ROC has the value 0, while the era ROC has the value 1.
-
isSupported
public boolean isSupported(TemporalField field)
Description copied from interface:TemporalAccessor
Checks if the specified field is supported.This checks if the date-time can be queried for the specified field. If false, then calling the
range
andget
methods will throw an exception.Specification for implementors
Implementations must check and handle all fields defined inChronoField
. If the field is supported, then true is returned, otherwise falseIf the field is not a
ChronoField
, then the result of this method is obtained by invokingTemporalField.isSupportedBy(TemporalAccessor)
passingthis
as the argument.Implementations must not alter this object.
- Specified by:
isSupported
in interfaceTemporalAccessor
- Parameters:
field
- the field to check, null returns false- Returns:
- true if this date-time can be queried for the field, false if not
-
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 inChronoField
. If the field is supported, then the range of the field must be returned. If unsupported, then aDateTimeException
must be thrown.If the field is not a
ChronoField
, then the result of this method is obtained by invokingTemporalField.rangeRefinedBy(TemporalAccessorl)
passingthis
as the argument.Implementations must not alter either this object.
- Specified by:
range
in interfaceTemporalAccessor
- Parameters:
field
- the field to query the range for, not null- Returns:
- the range of valid values for the field, not null
-
get
public int get(TemporalField field)
Description copied from interface:TemporalAccessor
Gets the value of the specified field as anint
.This queries the date-time for the value for the specified field. The returned value will always be within the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.
Specification for implementors
Implementations must check and handle all fields defined inChronoField
. If the field is supported and has anint
range, then the value of the field must be returned. If unsupported, then aDateTimeException
must be thrown.If the field is not a
ChronoField
, then the result of this method is obtained by invokingTemporalField.getFrom(TemporalAccessor)
passingthis
as the argument.Implementations must not alter either this object.
- Specified by:
get
in interfaceTemporalAccessor
- Parameters:
field
- the field to get, not null- Returns:
- the value for the field, within the valid range of values
-
getLong
public long getLong(TemporalField field)
Description copied from interface:TemporalAccessor
Gets the value of the specified field as along
.This queries the date-time for the value for the specified field. The returned value may be outside the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.
Specification for implementors
Implementations must check and handle all fields defined inChronoField
. If the field is supported, then the value of the field must be returned. If unsupported, then aDateTimeException
must be thrown.If the field is not a
ChronoField
, then the result of this method is obtained by invokingTemporalField.getFrom(TemporalAccessor)
passingthis
as the argument.Implementations must not alter either this object.
- Specified by:
getLong
in interfaceTemporalAccessor
- Parameters:
field
- the field to get, not null- Returns:
- the value for the field
-
adjustInto
public Temporal adjustInto(Temporal temporal)
Description copied from interface:TemporalAdjuster
Adjusts the specified temporal object.This adjusts the specified temporal object using the logic encapsulated in the implementing class. Examples might be an adjuster that sets the date avoiding weekends, or one that sets the date to the last day of the month.
There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use
Temporal.with(TemporalAdjuster)
:// these two lines are equivalent, but the second approach is recommended temporal = thisAdjuster.adjustInto(temporal); temporal = temporal.with(thisAdjuster);
It is recommended to use the second approach,with(TemporalAdjuster)
, as it is a lot clearer to read in code.Specification for implementors
The implementation must take the input object and adjust it. The implementation defines the logic of the adjustment and is responsible for documenting that logic. It may use any method onTemporal
to query the temporal object and perform the adjustment. The returned object must have the same observable type as the input objectThe input object must not be altered. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable temporal objects.
The input temporal object may be in a calendar system other than ISO. Implementations may choose to document compatibility with other calendar systems, or reject non-ISO temporal objects by
querying the chronology
.This method may be called from multiple threads in parallel. It must be thread-safe when invoked.
- Specified by:
adjustInto
in interfaceTemporalAdjuster
- Parameters:
temporal
- the temporal object to adjust, not null- Returns:
- an object of the same observable type with the adjustment made, not null
-
query
public <R> R query(TemporalQuery<R> query)
Description copied from interface:TemporalAccessor
Queries this date-time.This queries this date-time using the specified query strategy object.
Queries are a key tool for extracting information from date-times. They exists to externalize the process of querying, permitting different approaches, as per the strategy design pattern. Examples might be a query that checks if the date is the day before February 29th in a leap year, or calculates the number of days to your next birthday.
The most common query implementations are method references, such as
LocalDate::from
andZoneId::from
. Further implementations are onTemporalQueries
. Queries may also be defined by applications.Specification for implementors
Implementations of this method must behave as follows:public <R> R query(TemporalQuery<R> type) { // only include an if statement if the implementation can return it if (query == TemporalQueries.zoneId()) return // the ZoneId if (query == TemporalQueries.chronology()) return // the Chrono if (query == TemporalQueries.precision()) return // the precision // call default method return super.query(query); }
- Specified by:
query
in interfaceTemporalAccessor
- Type Parameters:
R
- the type of the result- Parameters:
query
- the query to invoke, not null- Returns:
- the query result, null may be returned (defined by the query)
-
getDisplayName
public String getDisplayName(TextStyle style, Locale locale)
Description copied from interface:Era
Gets the textual representation of this era.This returns the textual name used to identify the era. The parameters control the style of the returned text and the locale.
If no textual mapping is found then the
numeric value
is returned.- Specified by:
getDisplayName
in interfaceEra
- Parameters:
style
- the style of the text required, not nulllocale
- the locale to use, not null- Returns:
- the text value of the era, not null
-
-