|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Object java.lang.Enum<MonthOfYear> javax.time.calendar.MonthOfYear
public enum MonthOfYear
A month-of-year, such as 'July'.
MonthOfYear
is an enum representing the 12 months of the year -
January, February, March, April, May, June, July, August, September, October,
November and December.
In addition to the textual enum name, each month-of-year has an int
value.
The int
value follows normal usage and the ISO-8601 standard,
from 1 (January) to 12 (December). 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 MonthOfYear
.
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 | |
---|---|
APRIL
The singleton instance for the month of April with 30 days. |
|
AUGUST
The singleton instance for the month of August with 31 days. |
|
DECEMBER
The singleton instance for the month of December with 31 days. |
|
FEBRUARY
The singleton instance for the month of February with 28 days, or 29 in a leap year. |
|
JANUARY
The singleton instance for the month of January with 31 days. |
|
JULY
The singleton instance for the month of July with 31 days. |
|
JUNE
The singleton instance for the month of June with 30 days. |
|
MARCH
The singleton instance for the month of March with 31 days. |
|
MAY
The singleton instance for the month of May with 31 days. |
|
NOVEMBER
The singleton instance for the month of November with 30 days. |
|
OCTOBER
The singleton instance for the month of October with 31 days. |
|
SEPTEMBER
The singleton instance for the month of September with 30 days. |
Method Summary | ||
---|---|---|
static MonthOfYear |
from(Calendrical... calendricals)
Obtains an instance of MonthOfYear from a set of calendricals. |
|
|
get(CalendricalRule<T> ruleToDerive)
Gets the value of the specified calendrical rule. |
|
int |
getLastDayOfMonth(boolean leapYear)
Gets the day-of-month for last day of this month. |
|
int |
getMonthEndDayOfYear(boolean leapYear)
Gets the day-of-year for the last day of this month. |
|
int |
getMonthOfQuarter()
Gets the index of the month within the quarter. |
|
int |
getMonthStartDayOfYear(boolean leapYear)
Gets the day-of-year for the first day of this month. |
|
QuarterOfYear |
getQuarterOfYear()
Gets the quarter that this month falls in. |
|
java.lang.String |
getText(TextStyle style,
java.util.Locale locale)
Gets the textual representation, such as 'Jan' or 'December'. |
|
int |
getValue()
Gets the month-of-year int value. |
|
int |
lengthInDays(boolean leapYear)
Gets the length of this month in days. |
|
boolean |
matchesCalendrical(Calendrical calendrical)
Checks if the month-of-year extracted from the calendrical matches this. |
|
int |
maxLengthInDays()
Gets the maximum length of this month in days. |
|
int |
minLengthInDays()
Gets the minimum length of this month in days. |
|
MonthOfYear |
next()
Gets the next month-of-year. |
|
static MonthOfYear |
of(int monthOfYear)
Obtains an instance of MonthOfYear from an int value. |
|
MonthOfYear |
previous()
Gets the previous month-of-year. |
|
MonthOfYear |
roll(int months)
Rolls the month-of-year, adding the specified number of months. |
|
static CalendricalRule<MonthOfYear> |
rule()
Gets the rule for MonthOfYear . |
|
DateTimeField |
toField()
Converts this month-of-year to an equivalent field. |
|
static MonthOfYear |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. |
|
static MonthOfYear[] |
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 MonthOfYear JANUARY
1
.
public static final MonthOfYear FEBRUARY
2
.
public static final MonthOfYear MARCH
3
.
public static final MonthOfYear APRIL
4
.
public static final MonthOfYear MAY
5
.
public static final MonthOfYear JUNE
6
.
public static final MonthOfYear JULY
7
.
public static final MonthOfYear AUGUST
8
.
public static final MonthOfYear SEPTEMBER
9
.
public static final MonthOfYear OCTOBER
10
.
public static final MonthOfYear NOVEMBER
11
.
public static final MonthOfYear DECEMBER
12
.
Method Detail |
---|
public static MonthOfYear[] values()
for (MonthOfYear c : MonthOfYear.values()) System.out.println(c);
public static MonthOfYear 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<MonthOfYear> rule()
MonthOfYear
.
This rule is a calendrical rule based on MonthOfYear
.
The equivalent date-time rule is ISODateTimeRule.MONTH_OF_YEAR
.
public static MonthOfYear of(int monthOfYear)
MonthOfYear
from an int
value.
MonthOfYear
is an enum representing the 12 months of the year.
This factory allows the enum to be obtained from the int
value.
The int
value follows the ISO-8601 standard, from 1 (January) to 12 (December).
An exception is thrown if the value is invalid. The exception uses the
ISOChronology
month-of-year rule to indicate the failed rule.
monthOfYear
- the month-of-year to represent, from 1 (January) to 12 (December)
IllegalCalendarFieldValueException
- if the month-of-year is invalidpublic static MonthOfYear from(Calendrical... calendricals)
MonthOfYear
from a set of calendricals.
A calendrical represents some form of date and time information. This method combines the input calendricals into a month-of-year.
calendricals
- the calendricals to create a month-of-year from, no nulls, not null
CalendricalException
- if unable to merge to a month-of-yearpublic <T> T get(CalendricalRule<T> ruleToDerive)
This will only return a value for the ISODateTimeRule.MONTH_OF_YEAR
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 the ISO-8601 standard, from 1 (January) to 12 (December).
public java.lang.String getText(TextStyle style, java.util.Locale locale)
This method is notionally specific to ISOChronology
as it uses
the month-of-year rule to obtain the text. However, it is expected that
the text will be equivalent for all month-of-year 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 MonthOfYear next()
This calculates based on the time-line, thus it rolls around the end of the year. The next month after December is January.
public MonthOfYear previous()
This calculates based on the time-line, thus it rolls around the end of the year. The previous month before January is December.
public MonthOfYear roll(int months)
This calculates based on the time-line, thus it rolls around the end of the year from December to January. The months to roll by may be negative.
This instance is immutable and unaffected by this method call.
months
- the months to roll by, positive or negative
public int lengthInDays(boolean leapYear)
This takes a flag to determine whether to return the length for a leap year or not.
February has 28 days in a standard year and 29 days in a leap year. April, June, September and November have 30 days. All other months have 31 days.
leapYear
- true if the length is required for a leap year
public int minLengthInDays()
February has a minimum length of 28 days. April, June, September and November have 30 days. All other months have 31 days.
public int maxLengthInDays()
February has a maximum length of 29 days. April, June, September and November have 30 days. All other months have 31 days.
public int getLastDayOfMonth(boolean leapYear)
This is a synonym for lengthInDays(boolean)
and exists to provide
a more meaningful API.
leapYear
- true if the length is required for a leap year
public int getMonthStartDayOfYear(boolean leapYear)
This returns the day-of-year that this month begins on, using the leap year flag to determine the length of February.
leapYear
- true if the length is required for a leap year
public int getMonthEndDayOfYear(boolean leapYear)
This returns the day-of-year that this month ends on, using the leap year flag to determine the length of February.
leapYear
- true if the length is required for a leap year
public QuarterOfYear getQuarterOfYear()
January to March are Q1, April to June are Q2, July to September are Q3 and October to December are Q4.
public int getMonthOfQuarter()
January, April, July and October will return 1. February, May, August and November will return 2. March, June, September and December will return 3.
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.MONTH_OF_YEAR
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |