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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionApril with the numerical ISO-value4
.August with the numerical ISO-value8
.December with the numerical ISO-value12
.February with the numerical ISO-value2
.January with the numerical ISO-value1
.July with the numerical ISO-value7
.June with the numerical ISO-value6
.March with the numerical ISO-value3
.May with the numerical ISO-value5
.November with the numerical ISO-value11
.October with the numerical ISO-value10
.September with the numerical ISO-value9
. -
Method Summary
Modifier and TypeMethodDescriptionAdjusts given entity and yields a changed copy of argument.static Month
atEndOfQuarterYear(Quarter quarterOfYear)
Gets the last month of given quarter of year.static Month
atStartOfQuarterYear(Quarter quarterOfYear)
Gets the first month of given quarter of year.static Month
Conversion from thejava.time
-equivalent.getDisplayName(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.int
getLength(int year)
Calculates the maximum length of this month in days dependent on given year (taking into account leap years).Calculates the corresponding quarter of year.int
getValue()
Gets the corresponding numerical value.next()
Rolls to the next month.static Month
parse(CharSequence text, Locale locale, TextWidth width, OutputContext context)
Tries to interprete given text as month.previous()
Rolls to the previous month.roll(int months)
Rolls this month by given amount of months.boolean
test(GregorianDate context)
Decides if given context matches this condition.Conversion to thejava.time
-equivalent.static Month
valueOf(int month)
Gets the enum-constant which corresponds to the given numerical value.static Month
Returns the enum constant of this class with the specified name.static Month[]
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
Methods inherited from interface net.time4j.engine.ThreetenAdapter
get, getLong, isSupported, query, range
-
Enum Constant Details
-
JANUARY
January with the numerical ISO-value1
. -
FEBRUARY
February with the numerical ISO-value2
. -
MARCH
March with the numerical ISO-value3
. -
APRIL
April with the numerical ISO-value4
. -
MAY
May with the numerical ISO-value5
. -
JUNE
June with the numerical ISO-value6
. -
JULY
July with the numerical ISO-value7
. -
AUGUST
August with the numerical ISO-value8
. -
SEPTEMBER
September with the numerical ISO-value9
. -
OCTOBER
October with the numerical ISO-value10
. -
NOVEMBER
November with the numerical ISO-value11
. -
DECEMBER
December with the numerical ISO-value12
.
-
-
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
-
valueOf
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
Calculates the corresponding quarter of year.
- Returns:
- quarter of year
-
atStartOfQuarterYear
Gets the first month of given quarter of year.
- Parameters:
quarterOfYear
- quarter of year (Q1-Q4)- Returns:
- first month in given quarteryear
-
atEndOfQuarterYear
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
Rolls to the next month.
The result is January if applied on December.
- Returns:
- next month (rolling at December)
-
previous
Rolls to the previous month.
The result is December if applied on January.
- Returns:
- previous month (rolling at January)
-
roll
Rolls this month by given amount of months.
- Parameters:
months
- count of months (maybe negative)- Returns:
- result of rolling operation
-
getDisplayName
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
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
)
-
parse
public static Month parse(CharSequence text, Locale locale, TextWidth width, OutputContext context) throws ParseExceptionTries to interprete given text as month.
- Parameters:
text
- the text to be parsedlocale
- language settingwidth
- expected text widthcontext
- 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
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 interfaceChronoCondition<GregorianDate>
- Specified by:
test
in interfacePredicate<GregorianDate>
- Parameters:
context
- context as base of testing this condition- Returns:
true
if given time context matches this condition elsefalse
-
toTemporalAccessor
Conversion to the
java.time
-equivalent.- Specified by:
toTemporalAccessor
in interfaceThreetenAdapter
- Returns:
- java.time.Month
- Since:
- 4.28
- See Also:
from(java.time.Month)
-
from
Conversion from the
java.time
-equivalent.- Parameters:
threetenMonth
- month value to be converted- Returns:
- Month
- Since:
- 4.28
- See Also:
toTemporalAccessor()
-
apply
Description copied from interface:ChronoOperator
Adjusts given entity and yields a changed copy of argument.
Will be called by
ChronoEntity.with(ChronoOperator)
.
-