public enum Month extends Enum<Month>
Enum Constant and Description |
---|
APRIL
四月
|
AUGUST
八月
|
DECEMBER
十二月
|
FEBRUARY
二月
|
JANUARY
一月
|
JULY
七月
|
JUNE
六月
|
MARCH
三月
|
MAY
五月
|
NOVEMBER
十一月
|
OCTOBER
十月
|
SEPTEMBER
九月
|
UNDECIMBER
十三月,仅用于农历
|
Modifier and Type | Method and Description |
---|---|
String |
getDisplayName(TextStyle style)
获取显示名称
|
String |
getDisplayName(TextStyle style,
Locale locale)
获取显示名称
|
int |
getLastDay(boolean isLeapYear)
获取此月份最后一天的值,不支持的月份(例如UNDECIMBER)返回-1
|
static int |
getLastDay(int month,
boolean isLeapYear)
获得指定月的最后一天
|
int |
getValue()
获取
Calendar 中的对应值此值从0开始,即0表示一月 |
int |
getValueBaseOne()
获取月份值,此值与
Month 对应此值从1开始,即1表示一月 |
static Month |
of(int calendarMonthIntValue)
|
static Month |
of(Month month)
Month 转换为Month对象 |
static Month |
of(String name)
解析别名为Month对象,别名如:jan或者JANUARY,不区分大小写
|
Month |
toJdkMonth()
转换为
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 final Month UNDECIMBER
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 getValueBaseOne()
Month
对应Month
,从1开始计数public int getLastDay(boolean isLeapYear)
isLeapYear
- 是否闰年public static Month of(int calendarMonthIntValue)
calendarMonthIntValue
- Calendar中关于Month的int值,从0开始Calendar.JANUARY
,
Calendar.FEBRUARY
,
Calendar.MARCH
,
Calendar.APRIL
,
Calendar.MAY
,
Calendar.JUNE
,
Calendar.JULY
,
Calendar.AUGUST
,
Calendar.SEPTEMBER
,
Calendar.OCTOBER
,
Calendar.NOVEMBER
,
Calendar.DECEMBER
,
Calendar.UNDECIMBER
public static Month of(String name) throws IllegalArgumentException
name
- 别名值IllegalArgumentException
- 如果别名无对应的枚举,抛出此异常public static Month of(Month month)
Month
转换为Month对象month
- Month
public static int getLastDay(int month, boolean isLeapYear)
month
- 月份,从0开始isLeapYear
- 是否为闰年,闰年只对二月有影响public String getDisplayName(TextStyle style)
style
- 名称风格Copyright © 2024. All rights reserved.