AmPm is an enum representing the half-day concepts of AM and PM.
AM is defined as from 00:00 to 11:59, while PM is defined from 12:00 to 23:59.
All date-time fields have an int value.
The int value follows Calendar, assigning 0 to AM and 1 to PM.
It is recommended that applications use the enum rather than the int value
to ensure code clarity.
Do not use ordinal() to obtain the numeric representation of AmPm.
Use getValue() instead.
This enum represents a common concept that is found in many calendar systems. As such, this enum may be used by any calendar system that has the AM/PM concept defined exactly equivalent to the ISO calendar system.
| Modifier and Type | Field and Description |
|---|---|
| public static final AmPm | AM
The singleton instance for the morning, AM - ante meridiem. |
| public static final AmPm | PM
The singleton instance for the afternoon, PM - post meridiem. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Temporal | Returns: the adjusted object, not nullthe target object to be adjusted, not null temporal)Implements java. Adjusts the specified temporal object to have this am-pm value. |
| public static AmPm | Returns: the AM/PM, not nullthe temporal object to convert, not null temporal)Obtains an instance of |
| public int | Returns: the value for the field, within the valid range of valuesthe field to get, not null field)Overrides default java. Gets the value of the specified field from this am-pm as an |
| public String | Returns: the text value of the am-pm, not nullthe length of the text required, not null style, Locale the locale to use, not null locale)Gets the textual representation, such as 'AM' or 'PM'. |
| public long | Returns: the value for the fieldthe field to get, not null field)Implements java. Gets the value of the specified field from this am-pm as a |
| public int | |
| public boolean | Returns: true if the field is supported on this am-pm, false if notthe field to check, null returns false field)Implements java. Checks if the specified field is supported. |
| public static AmPm | Returns: the AM/PM, not nullthe AM/PM value to represent, from 0 (AM) to 1 (PM) amPmValue)Obtains an instance of |
| public static AmPm | Returns: the AM/PM, not nullthe hour-of-day to extract from, from 0 to 23 hourOfDay)Obtains an instance of |
| public < the type of the result R> R | Returns: the query result, null may be returned (defined by the query)the query to invoke, not null query)Overrides default java. Queries this am-pm using the specified query. |
| 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. Gets the range of valid values for the specified field. |
| public static AmPm | |
| public static AmPm[] |
| AM | back to summary |
|---|---|
| public static final AmPm AM The singleton instance for the morning, AM - ante meridiem.
This has the numeric value of | |
| PM | back to summary |
|---|---|
| public static final AmPm PM The singleton instance for the afternoon, PM - post meridiem.
This has the numeric value of | |
| AmPm | back to summary |
|---|---|
| private AmPm() | |
| adjustInto | back to summary |
|---|---|
| public Temporal adjustInto(Temporal temporal) Implements java. Adjusts the specified temporal object to have this am-pm value. This returns a temporal object of the same observable type as the input with the am-pm changed to be the same as this.
The adjustment is equivalent to using
In most cases, it is clearer to reverse the calling pattern by using
// these two lines are equivalent, but the second approach is recommended temporal = thisAmPm.adjustInto(temporal); temporal = temporal.with(thisAmPm); This instance is immutable and unaffected by this method call.
| |
| from | back to summary |
|---|---|
| public static AmPm from(TemporalAccessor temporal) Obtains an instance of
This obtains an am-pm based on the specified temporal.
A
The conversion extracts the
This method matches the signature of the functional interface
| |
| get | back to summary |
|---|---|
| public int get(TemporalField field) Overrides default java. Gets the value of the specified field from this am-pm as an This queries this am-pm for the value for the specified field. The returned value will always be within the valid range of values for the field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.
If the field is
If the field is not a
| |
| getDisplayName | back to summary |
|---|---|
| public String getDisplayName(TextStyle style, Locale locale) Gets the textual representation, such as 'AM' or 'PM'. This returns the textual name used to identify the am-pm, 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 | |
| getLong | back to summary |
|---|---|
| public long getLong(TemporalField field) Implements java. Gets the value of the specified field from this am-pm as a This queries this am-pm for the value for the specified field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.
If the field is
If the field is not a
| |
| getValue | back to summary |
|---|---|
| public int getValue() Gets the AM/PM
The values are numbered following
| |
| isSupported | back to summary |
|---|---|
| public boolean isSupported(TemporalField field) Implements java. Checks if the specified field is supported.
This checks if this am-pm can be queried for the specified field.
If false, then calling the
If the field is
If the field is not a
| |
| of | back to summary |
|---|---|
| public static AmPm of(int amPmValue) Obtains an instance of
| |
| ofHour | back to summary |
|---|---|
| public static AmPm ofHour(int hourOfDay) Obtains an instance of
| |
| query | back to summary |
|---|---|
| public <R> R query(TemporalQuery<R> query) Overrides default java. Queries this am-pm using the specified query.
This queries this am-pm using the specified query strategy object.
The
The result of this method is obtained by invoking the
| |
| 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 am-pm 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
If the field is not a
| |
| valueOf | back to summary |
|---|---|
| public static AmPm valueOf(String name) | |
| values | back to summary |
|---|---|
| public static AmPm[] values() | |