|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Object java.lang.Enum<AmPmOfDay> javax.time.calendar.AmPmOfDay
public enum AmPmOfDay
A half-day before or after midday, with the values 'AM' and 'PM'.
AmPmOfDay
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.
The calendrical framework requires date-time fields to 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 AmPmOfDay
.
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 month-of-year concept defined exactly equivalent to the ISO calendar system.
This is an immutable and thread-safe enum.
Enum Constant Summary | |
---|---|
AM
The singleton instance for the morning, AM - ante meridiem. |
|
PM
The singleton instance for the afternoon, PM - post meridiem. |
Method Summary | ||
---|---|---|
static AmPmOfDay |
from(Calendrical... calendricals)
Obtains an instance of AmPmOfDay from a set of calendricals. |
|
|
get(CalendricalRule<T> ruleToDerive)
Gets the value of the specified calendrical rule. |
|
java.lang.String |
getText(TextStyle style,
java.util.Locale locale)
Gets the textual representation, such as 'AM' or 'PM'. |
|
int |
getValue()
Gets the AM/PM int value. |
|
boolean |
matchesCalendrical(Calendrical calendrical)
Checks if the AM/PM extracted from the calendrical matches this. |
|
static AmPmOfDay |
of(int amPmOfDay)
Obtains an instance of AmPmOfDay from an int value. |
|
static CalendricalRule<AmPmOfDay> |
rule()
Gets the rule for AmPmOfDay . |
|
DateTimeField |
toField()
Converts this AM/PM to an equivalent field. |
|
static AmPmOfDay |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. |
|
static AmPmOfDay[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
Methods inherited from class java.lang.Enum |
---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
public static final AmPmOfDay AM
0
.
public static final AmPmOfDay PM
1
.
Method Detail |
---|
public static AmPmOfDay[] values()
for (AmPmOfDay c : AmPmOfDay.values()) System.out.println(c);
public static AmPmOfDay valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.
java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified name
java.lang.NullPointerException
- if the argument is nullpublic static CalendricalRule<AmPmOfDay> rule()
AmPmOfDay
.
This rule is a calendrical rule based on AmPmOfDay
.
The equivalent date-time rule is ISODateTimeRule.AMPM_OF_DAY
.
public static AmPmOfDay of(int amPmOfDay)
AmPmOfDay
from an int
value.
AmPmOfDay
is an enum representing before and after midday.
This factory allows the enum to be obtained from the int
value.
The int
value follows Calendar
, assigning 0 to AM and 1 to PM.
An exception is thrown if the value is invalid. The exception uses the
ISOChronology
AM/PM rule to indicate the failed rule.
amPmOfDay
- the AM/PM value to represent, from 0 (AM) to 1 (PM)
IllegalCalendarFieldValueException
- if the value is invalidpublic static AmPmOfDay from(Calendrical... calendricals)
AmPmOfDay
from a set of calendricals.
A calendrical represents some form of date and time information. This method combines the input calendricals into AM/PM.
calendricals
- the calendricals to create AM/PM from, no nulls, not null
CalendricalException
- if unable to merge to AM/PMpublic <T> T get(CalendricalRule<T> ruleToDerive)
This will only return a value for the ISODateTimeRule.AMPM_OF_DAY
rule, or something derivable from it.
get
in interface Calendrical
ruleToDerive
- the rule to derive, not null
public int getValue()
int
value.
The values are numbered following Calendar
, assigning 0 to AM and 1 to PM.
public java.lang.String getText(TextStyle style, java.util.Locale locale)
This method is notionally specific to ISOChronology
as it uses
the AM/PM rule to obtain the text. However, it is expected that
the text will be equivalent for all AM/PM rules, thus this aspect
of the implementation should be irrelevant to applications.
If no textual mapping is found then the numeric value
is returned.
locale
- the locale to use, not null
public boolean matchesCalendrical(Calendrical calendrical)
This method implements the CalendricalMatcher
interface.
It is intended that applications use LocalDate.matches(javax.time.calendar.CalendricalMatcher)
rather than this method.
matchesCalendrical
in interface CalendricalMatcher
calendrical
- the calendrical to match, not null
public DateTimeField toField()
The field is based on ISODateTimeRule.AMPM_OF_DAY
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |