Class TimeUtil


  • public class TimeUtil
    extends Object
    Class TimeUtil.
    • Method Detail

      • chronoUnitToTimeUnit

        public static TimeUnit chronoUnitToTimeUnit​(ChronoUnit chronoUnit)
        Converts a ChronoUnit to the equivalent TimeUnit.
        Parameters:
        chronoUnit - the ChronoUnit to convert
        Returns:
        the converted equivalent TimeUnit
        Throws:
        IllegalArgumentException - if chronoUnit has no equivalent TimeUnit
        NullPointerException - if chronoUnit is null
      • timeUnitToChronoUnit

        public static ChronoUnit timeUnitToChronoUnit​(TimeUnit timeUnit)
        Converts this TimeUnit to the equivalent ChronoUnit.
        Parameters:
        timeUnit - The TimeUnit
        Returns:
        the converted equivalent ChronoUnit
        Throws:
        IllegalArgumentException - if chronoUnit has no equivalent TimeUnit
        NullPointerException - if chronoUnit is null
      • convertToMillis

        public static long convertToMillis​(long duration,
                                           ChronoUnit chronoUnit)
        Converts a duration and its chrono unit to millis.
        Parameters:
        duration - The duration.
        chronoUnit - The unit of the duration.
        Returns:
        Milliseconds.
      • convertToNanos

        public static long convertToNanos​(long duration,
                                          ChronoUnit chronoUnit)
        Converts a duration and its chrono unit to nanos.
        Parameters:
        duration - The duration.
        chronoUnit - The unit of the duration.
        Returns:
        Nanoseconds.