Package net.time4j

Enum Class Meridiem

All Implemented Interfaces:
Serializable, Comparable<Meridiem>, java.lang.constant.Constable, Predicate<WallTime>, ChronoCondition<WallTime>

public enum Meridiem extends Enum<Meridiem> implements ChronoCondition<WallTime>

Represents the half day relative to noon.

Meno Hochschild
  • Enum Constant Details

    • AM

      public static final Meridiem AM

      Marks the wall time from midnight (at start of day) until before noon (ante meridiem).

      The numerical value is 0.

    • PM

      public static final Meridiem PM

      Marks the wall time at or after noon (post meridiem).

      The numerical value is 1.

  • Method Details

    • values

      public static Meridiem[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Meridiem valueOf(String name)
      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.)
      name - the name of the enum constant to be returned.
      the enum constant with the specified name
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • ofHour

      public static Meridiem ofHour(int hour)

      Calculates the meridiem value dependent on given hour of day.

      hour - ISO-hour in the range 0 <= hour <= 24
      half of day (ante meridiem or post meridiem)
      IllegalArgumentException - if the hour is out of range
      See Also:
    • getDisplayName

      public String getDisplayName(Locale locale)

      Equivalent to the expression getDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT).

      locale - language of text to be printed
      localized text in given language
    • getDisplayName

      public String getDisplayName(Locale locale, TextWidth width, OutputContext context)

      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).

      locale - language setting
      width - text width
      context - output context
      descriptive text for given locale and style (never null)
    • parse

      public static Meridiem parse(CharSequence text, Locale locale, TextWidth width, OutputContext context) throws ParseException

      Tries to interprete given text as AM/PM.

      The strings "am", "AM", "pm", "PM" are always understood.

      text - the text to be parsed
      locale - language setting
      width - expected text width
      context - expected output context
      the parsed meridiem if successful
      ParseException - if parsing fails
      See Also:
      getDisplayName(Locale, TextWidth, OutputContext)
    • test

      public boolean test(WallTime context)
      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
      Specified by:
      test in interface ChronoCondition<WallTime>
      Specified by:
      test in interface Predicate<WallTime>
      context - context as base of testing this condition
      true if given time context matches this condition else false