Class TimeUtil

java.lang.Object
es.urjc.etsii.grafo.util.TimeUtil

public class TimeUtil extends Object
Common time operations
  • Field Details

    • NANOS_IN_SECOND

      public static long NANOS_IN_SECOND
      Nanoseconds in 1 second
    • NANOS_IN_MILLISECOND

      public static long NANOS_IN_MILLISECOND
      Nanoseconds in 1 millisecond
  • Constructor Details

    • TimeUtil

      public TimeUtil()
  • Method Details

    • nanosToSecs

      public static double nanosToSecs(long nanos)
      Convert nanoseconds to seconds
      Parameters:
      nanos - nanoseconds
      Returns:
      seconds as a double value
    • secsToNanos

      public static long secsToNanos(double seconds)
      Convert seconds to nanos
      Parameters:
      seconds - seconds, can be a decimal number
      Returns:
      nanoseconds, discards decimals after the ninth.
    • convert

      public static long convert(long value, TimeUnit from, TimeUnit to)
      Convert time between different timeunits
      Parameters:
      value - value to convert
      from - TimeUnit of the value, example seconds
      to - desired TimeUnit, example Milliseconds
      Returns:
      converted value to the given TimeUnit