Enum Class Meridiem
- All Implemented Interfaces:
Serializable
,Comparable<Meridiem>
,java.lang.constant.Constable
,Predicate<WallTime>
,ChronoCondition<WallTime>
Represents the half day relative to noon.
- Author:
- Meno Hochschild
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetDisplayName(Locale locale)
Equivalent to the expressiongetDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT)
.getDisplayName(Locale locale, TextWidth width, OutputContext context)
Gets the description text dependent on the locale and style parameters.static Meridiem
ofHour(int hour)
Calculates the meridiem value dependent on given hour of day.static Meridiem
parse(CharSequence text, Locale locale, TextWidth width, OutputContext context)
Tries to interprete given text as AM/PM.boolean
Decides if given context matches this condition.static Meridiem
Returns the enum constant of this class with the specified name.static Meridiem[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
AM
Marks the wall time from midnight (at start of day) until before noon (ante meridiem).
The numerical value is
0
. -
PM
Marks the wall time at or after noon (post meridiem).
The numerical value is
1
.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException
- if the argument is null
-
ofHour
Calculates the meridiem value dependent on given hour of day.
- Parameters:
hour
- ISO-hour in the range0 <= hour <= 24
- Returns:
- half of day (ante meridiem or post meridiem)
- Throws:
IllegalArgumentException
- if the hour is out of range- See Also:
PlainTime.AM_PM_OF_DAY
-
getDisplayName
Equivalent to the expression
getDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT)
.- Parameters:
locale
- language of text to be printed- Returns:
- localized text in given language
-
getDisplayName
Gets the description text dependent on the locale and style parameters.
The second argument controls the width of description while the third argument is only relevant for languages which make a difference between stand-alone forms and embedded text forms (does not matter in English).
- Parameters:
locale
- language settingwidth
- text widthcontext
- output context- Returns:
- descriptive text for given locale and style (never
null
) - Since:
- 3.35/4.30
-
parse
public static Meridiem parse(CharSequence text, Locale locale, TextWidth width, OutputContext context) throws ParseExceptionTries to interprete given text as AM/PM.
The strings "am", "AM", "pm", "PM" are always understood.
- Parameters:
text
- the text to be parsedlocale
- language settingwidth
- expected text widthcontext
- expected output context- Returns:
- the parsed meridiem if successful
- Throws:
ParseException
- if parsing fails- Since:
- 3.35/4.30
- See Also:
getDisplayName(Locale, TextWidth, OutputContext)
-
test
Description copied from interface:ChronoCondition
Decides if given context matches this condition.
Due to better readability it is recommended to use following equivalent approach instead of this method::
import static net.time4j.Weekday.SATURDAY; import static net.time4j.Month.JANUARY; PlainDate date = PlainDate.of(2014, JANUARY, 25); System.out.println(SATURDAY.test(date)); // direct use System.out.println(date.matches(SATURDAY)); // recommended callback
-