Enum Class Month

java.lang.Object
java.lang.Enum<Month>
org.miaixz.bus.core.center.date.culture.en.Month
All Implemented Interfaces:
Serializable, Comparable<Month>, Constable

public enum Month extends Enum<Month>
月份枚举 与Calendar中的月份int值对应
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Enum Constant Details

    • JANUARY

      public static final Month JANUARY
      一月
    • FEBRUARY

      public static final Month FEBRUARY
      二月
    • MARCH

      public static final Month MARCH
      三月
    • APRIL

      public static final Month APRIL
      四月
    • MAY

      public static final Month MAY
      五月
    • JUNE

      public static final Month JUNE
      六月
    • JULY

      public static final Month JULY
      七月
    • AUGUST

      public static final Month AUGUST
      八月
    • SEPTEMBER

      public static final Month SEPTEMBER
      九月
    • OCTOBER

      public static final Month OCTOBER
      十月
    • NOVEMBER

      public static final Month NOVEMBER
      十一月
    • DECEMBER

      public static final Month DECEMBER
      十二月
    • UNDECIMBER

      public static final Month UNDECIMBER
      十三月,仅用于农历
  • Method Details

    • values

      public static Month[] 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

      public static Month valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • of

      public static Month of(int calendarMonthIntValue)
      Calendar月份相关值转换为Month枚举对象 未找到返回null
      Parameters:
      calendarMonthIntValue - Calendar中关于Month的int值,从0开始
      Returns:
      Month
      See Also:
    • of

      public static Month of(String name) throws IllegalArgumentException
      解析别名为Month对象,别名如:jan或者JANUARY,不区分大小写
      Parameters:
      name - 别名值
      Returns:
      月份枚举Month,非空
      Throws:
      IllegalArgumentException - 如果别名无对应的枚举,抛出此异常
    • of

      public static Month of(Month month)
      Month转换为Month对象
      Parameters:
      month - Month
      Returns:
      Month
    • getLastDay

      public static int getLastDay(int month, boolean isLeapYear)
      获得指定月的最后一天
      Parameters:
      month - 月份,从0开始
      isLeapYear - 是否为闰年,闰年只对二月有影响
      Returns:
      最后一天,可能为28,29,30,31
    • getValue

      public int getValue()
      获取Calendar中的对应值 此值从0开始,即0表示一月
      Returns:
      Calendar中的对应月份值,从0开始计数
    • getIsoValue

      public int getIsoValue()
      获取月份值,此值与Month对应 此值从1开始,即1表示一月
      Returns:
      月份值,对应Month,从1开始计数
    • getLastDay

      public int getLastDay(boolean isLeapYear)
      获取此月份最后一天的值 不支持 UNDECIMBER
      Parameters:
      isLeapYear - 是否闰年
      Returns:
      此月份最后一天的值
    • toJdkMonth

      public Month toJdkMonth()
      转换为Month
      Returns:
      Month
    • getDisplayName

      public String getDisplayName(TextStyle style)
      获取显示名称
      Parameters:
      style - 名称风格
      Returns:
      显示名称
    • getDisplayName

      public String getDisplayName(TextStyle style, Locale locale)
      获取显示名称
      Parameters:
      style - 名称风格
      locale - Locale
      Returns:
      显示名称