com.hazelcast.util

## Class TimeUtil

- java.lang.Object
- - com.hazelcast.util.TimeUtil

-     public final class TimeUtil
      extends Object

  Utility class for Time & unit conversions

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static long` | `timeInMsOrOneIfResultIsZero(long time, TimeUnit timeUnit)` Convert time to milliseconds based on the given time unit.
    `static long` | `timeInMsOrTimeIfNullUnit(long time, TimeUnit timeUnit)` Convert time to milliseconds based on the given time unit.
    `static long` | `zeroOutMs(long timestamp)` Cleans the milliseconds info from the timestamp

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### timeInMsOrOneIfResultIsZero

          public static long timeInMsOrOneIfResultIsZero(long time,
                                                         TimeUnit timeUnit)

      Convert time to milliseconds based on the given time unit. If conversion result is 0 and `time` was > 0, then 1 is returned.
      Parameters:
        `time` - The input time
        `timeUnit` - The time unit to base the conversion on
      Returns:
        The millisecond representation of the input time
      Throws:
        `NullPointerException` - if time unit is `null`

    - #### timeInMsOrTimeIfNullUnit

          public static long timeInMsOrTimeIfNullUnit(long time,
                                                      TimeUnit timeUnit)

      Convert time to milliseconds based on the given time unit. If time unit is null, then input time is treated as milliseconds.
      Parameters:
        `time` - The input time
        `timeUnit` - The time unit to base the conversion on
      Returns:
        The millisecond representation of the time based on the unit, or the time itself if the unit is `null`

    - #### zeroOutMs

          public static long zeroOutMs(long timestamp)

      Cleans the milliseconds info from the timestamp
      Parameters:
        `timestamp` - The input timestamp
      Returns:
        The timestamp with the milliseconds field filled with zeros

Copyright © 2020. All rights reserved.