Class TimeDuration

    • Constructor Detail

      • TimeDuration

        public TimeDuration()
    • Method Detail

      • getDuration

        @Nullable
        public Long getDuration()
        Gets the duration, interpreted according to the configured unit of time. A value of 0 means no restriction (unlimited), a value of -1 means the default system timeout.

        May be null if the duration is not set.

        Returns:
        The duration.
      • setDuration

        public void setDuration​(@Nullable
                                Long duration)
        Sets the duration, interpreted according to the configured unit of time. A value of 0 means no restriction (unlimited), a value of -1 means the default system timeout.

        May be null if the duration is not set.

        Parameters:
        duration - The duration.
      • getUnit

        public ETimeUnit getUnit()
        Gets the unit of time for the duration.
        Returns:
        The unit of time for the duration.
      • setUnit

        public void setUnit​(ETimeUnit unit)
        Sets the unit of time for the duration.
        Parameters:
        unit - The unit of time for the duration.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • to

        public long to​(ETimeUnit targetUnit)
        Converts the duration to the given unit of time.
        Parameters:
        targetUnit - The target unit of time.
        Returns:
        The duration in the target unit of time.
      • toDays

        public long toDays()
        Gets the duration in days.
        Returns:
        The duration in days.
      • toDuration

        public Duration toDuration()
        Converts this duration to a Duration.
        Returns:
        A Duration object representing the same duration.
      • toHours

        public long toHours()
        Gets the duration in hours.
        Returns:
        The duration in hours.
      • toMicroseconds

        public long toMicroseconds()
        Gets the duration in microseconds.
        Returns:
        The duration in microseconds.
      • toMilliseconds

        public long toMilliseconds()
        Gets the duration in milliseconds.
        Returns:
        The duration in milliseconds.
      • toMinutes

        public long toMinutes()
        Gets the duration in minutes.
        Returns:
        The duration in minutes.
      • toNanoseconds

        public long toNanoseconds()
        Gets the duration in nanoseconds.
        Returns:
        The duration in nanoseconds.
      • toSeconds

        public long toSeconds()
        Gets the duration in seconds.
        Returns:
        The duration in seconds.
      • toWeeks

        public long toWeeks()
        Gets the duration in weeks.
        Returns:
        The duration in weeks.
      • of

        public static TimeDuration of​(Long duration,
                                      ETimeUnit unit)
        Creates a new instance of TimeDuration with the given duration and unit of time.
        Parameters:
        duration - The duration, interpreted according to the given unit of time.
        unit - The unit of time for the duration.
        Returns:
        A new instance of TimeDuration with the given duration and unit of time.
      • ofDays

        public static TimeDuration ofDays​(long duration)
        Creates a new instance of TimeDuration with the given duration in days.
        Parameters:
        duration - The duration in days.
        Returns:
        A new instance of TimeDuration with the given duration in days.
      • ofEmpty

        public static TimeDuration ofEmpty​(ETimeUnit unit)
        Creates a new instance of TimeDuration with no duration and the given unit of time.
        Parameters:
        unit - The unit of time for the duration.
        Returns:
        A new instance of TimeDuration with no duration and the given unit of time.
      • ofHours

        public static TimeDuration ofHours​(long duration)
        Creates a new instance of TimeDuration with the given duration in hours.
        Parameters:
        duration - The duration in hours.
        Returns:
        A new instance of TimeDuration with the given duration in hours.
      • ofMicroseconds

        public static TimeDuration ofMicroseconds​(long duration)
        Creates a new instance of TimeDuration with the given duration in microseconds.
        Parameters:
        duration - The duration in microseconds.
        Returns:
        A new instance of TimeDuration with the given duration in microseconds.
      • ofMilliseconds

        public static TimeDuration ofMilliseconds​(long duration)
        Creates a new instance of TimeDuration with the given duration in milliseconds.
        Parameters:
        duration - The duration in milliseconds.
        Returns:
        A new instance of TimeDuration with the given duration in milliseconds.
      • ofMinutes

        public static TimeDuration ofMinutes​(long duration)
        Creates a new instance of TimeDuration with the given duration in minutes.
        Parameters:
        duration - The duration in minutes.
        Returns:
        A new instance of TimeDuration with the given duration in minutes.
      • ofNanoseconds

        public static TimeDuration ofNanoseconds​(long duration)
        Creates a new instance of TimeDuration with the given duration in nanoseconds.
        Parameters:
        duration - The duration in nanoseconds.
        Returns:
        A new instance of TimeDuration with the given duration in nanoseconds.
      • ofSeconds

        public static TimeDuration ofSeconds​(long duration)
        Creates a new instance of TimeDuration with the given duration in seconds.
        Parameters:
        duration - The duration in seconds.
        Returns:
        A new instance of TimeDuration with the given duration in seconds.
      • ofWeeks

        public static TimeDuration ofWeeks​(long duration)
        Creates a new instance of TimeDuration with the given duration in weeks.
        Parameters:
        duration - The duration in weeks.
        Returns:
        A new instance of TimeDuration with the given duration in weeks.