public enum Month extends Enum<Month>
This enum is mainly useful to parse data files that use month names like Jan or JAN or January or numbers like 1 or 01. It handles month numbers as well as three letters abbreviation and full names, independently of capitalization.
DateComponents
Enum Constant and Description |
---|
APRIL
April.
|
AUGUST
August.
|
DECEMBER
December.
|
FEBRUARY
February.
|
JANUARY
January.
|
JULY
July.
|
JUNE
June.
|
MARCH
March.
|
MAY
May.
|
NOVEMBER
November.
|
OCTOBER
October.
|
SEPTEMBER
September.
|
Modifier and Type | Method and Description |
---|---|
String |
getCapitalizedAbbreviation()
Get the capitalized three letters abbreviation.
|
String |
getCapitalizedName()
Get the capitalized full name.
|
String |
getLowerCaseAbbreviation()
Get the lower case three letters abbreviation.
|
String |
getLowerCaseName()
Get the lower case full name.
|
static Month |
getMonth(int number)
Get the month corresponding to a number.
|
int |
getNumber()
Get the month number.
|
String |
getUpperCaseAbbreviation()
Get the upper case three letters abbreviation.
|
String |
getUpperCaseName()
Get the upper case full name.
|
static Month |
parseMonth(String s)
Parse the string to get the month.
|
static Month |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Month[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Month JANUARY
public static final Month FEBRUARY
public static final Month MARCH
public static final Month APRIL
public static final Month MAY
public static final Month JUNE
public static final Month JULY
public static final Month AUGUST
public static final Month SEPTEMBER
public static final Month OCTOBER
public static final Month NOVEMBER
public static final Month DECEMBER
public static Month[] values()
for (Month c : Month.values()) System.out.println(c);
public static Month valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic int getNumber()
public String getUpperCaseName()
public String getLowerCaseName()
public String getCapitalizedName()
public String getUpperCaseAbbreviation()
public String getLowerCaseAbbreviation()
public String getCapitalizedAbbreviation()
public static Month parseMonth(String s)
The string can be either the month number, the full name or the three letter abbreviation. The parsing ignore the case of the specified string and trims surrounding blanks.
s
- string to parseIllegalArgumentException
- if the string does not correspond to a monthpublic static Month getMonth(int number)
number
- month numberIllegalArgumentException
- if the string does not correspond to a monthCopyright © 2002-2020 CS Group. All rights reserved.