Package io.time

Interface Time

All Known Implementing Classes:
MicroSeconds, MilliSeconds, NanoSeconds

public sealed interface Time permits MilliSeconds, MicroSeconds, NanoSeconds
Interface Time.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    MICROS_PER_MS = 1000.
    static final int
    MICROS_PER_SEC = MICROS_PER_MS * MS_PER_SEC.
    static final int
    MS_PER_MIN = MS_PER_SEC * 60.
    static final int
    MS_PER_SEC = 1000.
    static final int
    NS_PER_MICRO = 1000.
    static final int
    NS_PER_MS = NS_PER_MICRO * MICROS_PER_MS.
    static final long
    NS_PER_SEC = MS_PER_SEC * NS_PER_MS.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    convert the time to Micro seconds.
    double
    convert the time to Milliseconds.
    double
    convert the time to Nanoseconds.
    default long
    elapsed(long h, long l)
    get the duration between two time stamps.
    double
    elapsedMilliSeconds(long h, long l)
    get the elapsed Time in milliseconds.
    double
    elapsedSeconds(long h, long l)
    get the elapsed Time in seconds.
    long
    get the current Time.
    get the Time Unit.
  • Field Details

    • NS_PER_MICRO

      static final int NS_PER_MICRO
      NS_PER_MICRO = 1000.
      See Also:
    • MICROS_PER_MS

      static final int MICROS_PER_MS
      MICROS_PER_MS = 1000.
      See Also:
    • MS_PER_SEC

      static final int MS_PER_SEC
      MS_PER_SEC = 1000.
      See Also:
    • NS_PER_MS

      static final int NS_PER_MS
      NS_PER_MS = NS_PER_MICRO * MICROS_PER_MS.
      See Also:
    • NS_PER_SEC

      static final long NS_PER_SEC
      NS_PER_SEC = MS_PER_SEC * NS_PER_MS.
      See Also:
    • MS_PER_MIN

      static final int MS_PER_MIN
      MS_PER_MIN = MS_PER_SEC * 60.
      See Also:
    • MICROS_PER_SEC

      static final int MICROS_PER_SEC
      MICROS_PER_SEC = MICROS_PER_MS * MS_PER_SEC.
      See Also:
  • Method Details

    • getTimeUnit

      TimeUnit getTimeUnit()
      get the Time Unit.
      Returns:
      time Unit
    • getCurrentTime

      long getCurrentTime()
      get the current Time.
      Returns:
      current Time
    • elapsed

      default long elapsed(long h, long l)
      get the duration between two time stamps.
      Parameters:
      h - time stamp
      l - time stamp, the l should be less than h
      Returns:
      elapsed time.
    • elapsedMilliSeconds

      double elapsedMilliSeconds(long h, long l)
      get the elapsed Time in milliseconds.
      Parameters:
      h - time stamp
      l - time stamp, the l should be less than h
      Returns:
      elapsed time in milliseconds
    • elapsedSeconds

      double elapsedSeconds(long h, long l)
      get the elapsed Time in seconds.
      Parameters:
      h - time stamp
      l - time stamp, the l should be less than h
      Returns:
      elapsed time in seconds
    • convertToNanoSeconds

      double convertToNanoSeconds(double t)
      convert the time to Nanoseconds.
      Parameters:
      t - time duration
      Returns:
      converted time in nanoseconds
    • convertToMicroSeconds

      double convertToMicroSeconds(double t)
      convert the time to Micro seconds.
      Parameters:
      t - time duration
      Returns:
      converted time in microseconds
    • convertToMilliSeconds

      double convertToMilliSeconds(double t)
      convert the time to Milliseconds.
      Parameters:
      t - time duration
      Returns:
      converted time in Milliseconds