Era

An era of the time-line. !(p) Most calendar systems have a single epoch dividing the time-line into two eras. However, some calendar systems, have multiple eras, such as one for the reign of each leader. In all cases, the era is conceptually the largest division of the time-line. Each chronology defines the Era's that are known Eras and a {@link Chronology#eras Chronology.eras} to get the valid eras. !(p) For example, the Thai Buddhist calendar system divides time into two eras, before and after a single date. By contrast, the Japanese calendar system has one era for the reign of each Emperor. !(p) Instances of {@code Era} may be compared using the {@code ==} operator.

@implSpec This interface must be implemented with care to ensure other classes operate correctly. All implementations must be singletons - final, immutable and thread-safe. It is recommended to use an enum whenever possible.

@since 1.8

Members

Functions

getValue
int getValue()

Gets the numeric value associated with the era as defined by the chronology. Each chronology defines the predefined Eras and methods to list the Eras of the chronology. !(p) All fields, including eras, have an associated numeric value. The meaning of the numeric value for era is determined by the chronology according to these principles: !(ul) !(li)The era _in use at the epoch 1970-01-01 (ISO) has the value 1. !(li)Later eras have sequentially higher values. !(li)Earlier eras have sequentially lower values, which may be negative. </ul>

query
R query(TemporalQuery!(R) query)

Queries this era using the specified query. !(p) This queries this era using the specified query strategy object. The {@code TemporalQuery} object defines the logic to be used to obtain the result. Read the documentation of the query to understand what the result of this method will be. !(p) The result of this method is obtained by invoking the {@link TemporalQuery#queryFrom(TemporalAccessor)} method on the specified query passing {@code this} as the argument.

super_query
R super_query(TemporalQuery!(R) query)
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()

Gets the textual representation of this era. !(p) 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. !(p) If no textual mapping is found then the {@link #getValue() numeric value} is returned.

Inherited Members

From TemporalAccessor

isSupported
bool isSupported(TemporalField field)

Checks if the specified field is supported. !(p) This checks if the date-time can be queried for the specified field. If false, then calling the {@link #range(TemporalField) range} and {@link #get(TemporalField) get} methods will throw an exception.

range
ValueRange range(TemporalField field)

Gets the range of valid values for the specified field. !(p) All fields can be expressed as a {@code 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. !(p) 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.

get
int get(TemporalField field)

Gets the value of the specified field as an {@code int}. !(p) This queries the date-time for the value of 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.

getLong
long getLong(TemporalField field)

Gets the value of the specified field as a {@code long}. !(p) This queries the date-time for the value of 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.

query
R query(TemporalQuery!(R) query)

Queries this date-time. !(p) This queries this date-time using the specified query strategy object. !(p) 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. !(p) The most common query implementations are method references, such as {@code LocalDate::from} and {@code ZoneId::from}. Additional implementations are provided as static methods on {@link TemporalQuery}.

toString
string toString()
Undocumented in source.

From TemporalAdjuster

adjustInto
Temporal adjustInto(Temporal temporal)

Adjusts the specified temporal object. !(p) 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. !(p) There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use {@link Temporal#_with(TemporalAdjuster)}: !(pre) // these two lines are equivalent, but the second approach is recommended temporal = thisAdjuster.adjustInto(temporal); temporal = temporal._with(thisAdjuster); </pre> It is recommended to use the second approach, {@code _with(TemporalAdjuster)}, as it is a lot clearer to read _in code.

Meta