Enum Class Units

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

public enum Units extends Enum<Units>
日期时间单位,每个单位都是以毫秒为基数
Since:
Java 17+
Author:
Kimi Liu
  • Enum Constant Details

    • MS

      public static final Units MS
      一毫秒
    • SECOND

      public static final Units SECOND
      一秒的毫秒数
    • MINUTE

      public static final Units MINUTE
      一分钟的毫秒数
    • HOUR

      public static final Units HOUR
      一小时的毫秒数
    • DAY

      public static final Units DAY
      一天的毫秒数
    • WEEK

      public static final Units WEEK
      一周的毫秒数
  • Method Details

    • values

      public static Units[] 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 Units 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 Units of(ChronoUnit unit)
      单位兼容转换,将ChronoUnit转换为对应的DateUnit
      Parameters:
      unit - ChronoUnit
      Returns:
      Units,null表示不支持此单位
    • toChronoUnit

      public static ChronoUnit toChronoUnit(Units unit)
      单位兼容转换,将DateUnit转换为对应的ChronoUnit
      Parameters:
      unit - Units
      Returns:
      ChronoUnit
    • getMillis

      public long getMillis()
      Returns:
      单位对应的毫秒数
    • toChronoUnit

      public ChronoUnit toChronoUnit()
      单位兼容转换,将DateUnit转换为对应的ChronoUnit
      Returns:
      ChronoUnit