Package net.time4j

Enum Class Month

All Implemented Interfaces:
Serializable, Comparable<Month>, java.lang.constant.Constable, TemporalAccessor, Function<PlainDate,​PlainDate>, Predicate<GregorianDate>, UnaryOperator<PlainDate>, ChronoCondition<GregorianDate>, ChronoOperator<PlainDate>, ThreetenAdapter

Enumeration of months in ISO-8601-calendar.

Author:
Meno Hochschild
  • Enum Constant Details

    • JANUARY

      public static final Month JANUARY
      January with the numerical ISO-value 1.
    • FEBRUARY

      public static final Month FEBRUARY
      February with the numerical ISO-value 2.
    • MARCH

      public static final Month MARCH
      March with the numerical ISO-value 3.
    • APRIL

      public static final Month APRIL
      April with the numerical ISO-value 4.
    • MAY

      public static final Month MAY
      May with the numerical ISO-value 5.
    • JUNE

      public static final Month JUNE
      June with the numerical ISO-value 6.
    • JULY

      public static final Month JULY
      July with the numerical ISO-value 7.
    • AUGUST

      public static final Month AUGUST
      August with the numerical ISO-value 8.
    • SEPTEMBER

      public static final Month SEPTEMBER
      September with the numerical ISO-value 9.
    • OCTOBER

      public static final Month OCTOBER
      October with the numerical ISO-value 10.
    • NOVEMBER

      public static final Month NOVEMBER
      November with the numerical ISO-value 11.
    • DECEMBER

      public static final Month DECEMBER
      December with the numerical ISO-value 12.
  • Method Details

    • values

      public static Month[] 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

      public static Month 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.)
      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 name
      NullPointerException - if the argument is null
    • valueOf

      public static Month valueOf(int month)

      Gets the enum-constant which corresponds to the given numerical value.

      Parameters:
      month - gregorian month in the range [1-12]
      Returns:
      month of year as enum
      Throws:
      IllegalArgumentException - if given argument is out of range
    • getValue

      public int getValue()

      Gets the corresponding numerical value.

      Returns:
      number of month in the range [1-12]
    • getQuarterOfYear

      public Quarter getQuarterOfYear()

      Calculates the corresponding quarter of year.

      Returns:
      quarter of year
    • atStartOfQuarterYear

      public static Month atStartOfQuarterYear(Quarter quarterOfYear)

      Gets the first month of given quarter of year.

      Parameters:
      quarterOfYear - quarter of year (Q1-Q4)
      Returns:
      first month in given quarteryear
    • atEndOfQuarterYear

      public static Month atEndOfQuarterYear(Quarter quarterOfYear)

      Gets the last month of given quarter of year.

      Parameters:
      quarterOfYear - quarter of year (Q1-Q4)
      Returns:
      last month in given quarteryear
    • getLength

      public int getLength(int year)

      Calculates the maximum length of this month in days dependent on given year (taking into account leap years).

      Parameters:
      year - proleptic iso year
      Returns:
      length of month in days
    • next

      public Month next()

      Rolls to the next month.

      The result is January if applied on December.

      Returns:
      next month (rolling at December)
    • previous

      public Month previous()

      Rolls to the previous month.

      The result is December if applied on January.

      Returns:
      previous month (rolling at January)
    • roll

      public Month roll(int months)

      Rolls this month by given amount of months.

      Parameters:
      months - count of months (maybe negative)
      Returns:
      result of rolling operation
    • getDisplayName

      public String getDisplayName(Locale locale)

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

      Parameters:
      locale - language setting
      Returns:
      descriptive text (long form, never null)
      See Also:
      getDisplayName(Locale, TextWidth, OutputContext)
    • 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).

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

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

      Tries to interprete given text as month.

      Parameters:
      text - the text to be parsed
      locale - language setting
      width - expected text width
      context - expected output context
      Returns:
      the parsed month if successful
      Throws:
      ParseException - if parsing fails
      Since:
      3.33/4.28
      See Also:
      getDisplayName(Locale, TextWidth, OutputContext)
    • test

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

      public Month toTemporalAccessor()

      Conversion to the java.time-equivalent.

      Specified by:
      toTemporalAccessor in interface ThreetenAdapter
      Returns:
      java.time.Month
      Since:
      4.28
      See Also:
      from(java.time.Month)
    • from

      public static Month from(Month threetenMonth)

      Conversion from the java.time-equivalent.

      Parameters:
      threetenMonth - month value to be converted
      Returns:
      Month
      Since:
      4.28
      See Also:
      toTemporalAccessor()
    • apply

      public PlainDate apply(PlainDate date)
      Description copied from interface: ChronoOperator

      Adjusts given entity and yields a changed copy of argument.

      Will be called by ChronoEntity.with(ChronoOperator).

      Specified by:
      apply in interface ChronoOperator<PlainDate>
      Specified by:
      apply in interface Function<PlainDate,​PlainDate>
      Parameters:
      date - chronological entity to be adjusted
      Returns:
      adjusted copy of argument which itself remains unaffected