|
|||||||||
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 with a twelve month year where the names and month lengths are equivalent to
those defined. Note that the implementation of DateTimeFieldRule
for month-of-year
may vary by calendar system.
MonthOfYear 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 | ||
---|---|---|
|
get(CalendricalRule<T> rule)
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 |
getShortText(java.util.Locale locale)
Gets the short textual representation of this month-of-year, such as 'Jan' or 'Dec'. |
|
java.lang.String |
getText(java.util.Locale locale)
Gets the full textual representation of this month-of-year, such as 'January' or 'December'. |
|
int |
getValue()
Gets the month-of-year int value. |
|
boolean |
isApril()
Is this instance representing April. |
|
boolean |
isAugust()
Is this instance representing August. |
|
boolean |
isDecember()
Is this instance representing December. |
|
boolean |
isFebruary()
Is this instance representing February. |
|
boolean |
isJanuary()
Is this instance representing January. |
|
boolean |
isJuly()
Is this instance representing July. |
|
boolean |
isJune()
Is this instance representing June. |
|
boolean |
isMarch()
Is this instance representing March. |
|
boolean |
isMay()
Is this instance representing May. |
|
boolean |
isNovember()
Is this instance representing November. |
|
boolean |
isOctober()
Is this instance representing October. |
|
boolean |
isSeptember()
Is this instance representing September. |
|
int |
lengthInDays(boolean leapYear)
Gets the length of this month in days. |
|
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 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 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 int getValue()
int
value.
The values are numbered following the ISO-8601 standard, from 1 (January) to 12 (December).
public <T> T get(CalendricalRule<T> rule)
This returns the one of the month values if the type of the rule
is MonthOfYear
. Other rules will return null
.
get
in interface Calendrical
rule
- the rule to use, not null
public java.lang.String getShortText(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 there is no textual mapping for the locale, then the value is
returned as per Integer.toString()
.
locale
- the locale to use, not null
public java.lang.String getText(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 there is no textual mapping for the locale, then the value is
returned as per Integer.toString()
.
locale
- the locale to use, not null
public boolean isJanuary()
public boolean isFebruary()
public boolean isMarch()
public boolean isApril()
public boolean isMay()
public boolean isJune()
public boolean isJuly()
public boolean isAugust()
public boolean isSeptember()
public boolean isOctober()
public boolean isNovember()
public boolean isDecember()
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |