Enum DurationUnit

    • Method Detail

      • values

        public static DurationUnit[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (DurationUnit c : DurationUnit.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static DurationUnit valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
        NullPointerException - if the argument is null
      • toTemporalUnit

        public ChronoUnit toTemporalUnit()
      • toDuration

        public Duration toDuration()
      • toMilliseconds

        public long toMilliseconds()
      • toMilliseconds

        public long toMilliseconds​(long amount)
      • toSeconds

        public long toSeconds()
      • toSeconds

        public long toSeconds​(long amount)
      • toMinutes

        public long toMinutes()
      • toMinutes

        public long toMinutes​(long amount)
      • toHours

        public long toHours()
      • toHours

        public long toHours​(long amount)
      • toDays

        public long toDays()
      • toDays

        public long toDays​(long amount)
      • toWeeks

        public long toWeeks()
      • toWeeks

        public long toWeeks​(long amount)
      • toMonths

        public long toMonths()
      • toMonths

        public long toMonths​(long amount)
      • toYears

        public long toYears()
      • toYears

        public long toYears​(long amount)
      • toUnit

        public long toUnit​(DurationUnit targetUnit,
                           long amount)
      • from

        public static DurationUnit from​(Duration duration)
        Gets the largest unit fitting in the provided duration. If the duration is null, zero, or less, null is returned.
        Parameters:
        duration - duration in milliseconds
        Returns:
        duration unit
      • from

        public static DurationUnit from​(long duration)
        Gets the largest unit fitting in the provided duration. If the duration is zero or less, null is returned.
        Parameters:
        duration - duration in milliseconds
        Returns:
        duration unit
      • from

        public static DurationUnit from​(String unit)
        Gets the DurationUnit matching the provided string (case insensitive) or null if there are no units matching.
        Parameters:
        unit - unit name
        Returns:
        duration unit
      • reverseValues

        public static DurationUnit[] reverseValues()
        Returns all units from the highest (year), to the smallest (milliseconds).
        Returns:
        duration units
      • reverseOrdinal

        public int reverseOrdinal()
        Gets ordinal value in reverse order.
        Returns:
        ordinal value