Class TimeUtils

java.lang.Object
com.castlabs.utils.TimeUtils

public class TimeUtils extends Object
Utilities around time
Since:
3.3.0
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    ms2s(long milliseconds)
    Converts Milliseconds to Seconds
    static long
    ms2us(long milliseconds)
    Converts Milliseconds to Microseconds
    static long
    ns2ms(long nanoseconds)
    Converts Nanoseconds to Milliseconds
    static long
    s2ms(double seconds)
    Converts Seconds (double) to Milliseconds (long) e.g.
    static long
    s2ms(long seconds)
    Converts Seconds to Milliseconds
    static long
    s2us(double seconds)
    Converts Seconds (double) to Microseconds (long) e.g.
    static long
    s2us(long seconds)
    Converts Seconds to Microseconds
    static long
    Takes a string of the form "HH:MM:SS", "MM:SS", or "SS" and converts it to milliseconds.
    static long
    us2ms(long microseconds)
    Converts Microseconds to Milliseconds
    static long
    us2s(long microseconds)
    Converts Microseconds to Seconds

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TimeUtils

      public TimeUtils()
  • Method Details

    • timeToMilliseconds

      public static long timeToMilliseconds(String input)
      Takes a string of the form "HH:MM:SS", "MM:SS", or "SS" and converts it to milliseconds.
      Parameters:
      input - The input
      Returns:
      TimeMS from input string
      Throws:
      IllegalArgumentException - in case the input could not be parsed successfully
    • ms2us

      public static long ms2us(long milliseconds)
      Converts Milliseconds to Microseconds
      Parameters:
      milliseconds - Time in milliseconds
      Returns:
      Microseconds
    • s2us

      public static long s2us(long seconds)
      Converts Seconds to Microseconds
      Parameters:
      seconds - Time in seconds
      Returns:
      Microseconds
    • s2us

      public static long s2us(double seconds)
      Converts Seconds (double) to Microseconds (long) e.g. 123.4567s is converted into 123456700us
      Parameters:
      seconds - Time in seconds
      Returns:
      Microseconds
    • s2ms

      public static long s2ms(long seconds)
      Converts Seconds to Milliseconds
      Parameters:
      seconds - Time in seconds
      Returns:
      Milliseconds
    • s2ms

      public static long s2ms(double seconds)
      Converts Seconds (double) to Milliseconds (long) e.g. 123.4567s is converted into 123456ms
      Parameters:
      seconds - Time in seconds
      Returns:
      Milliseconds
    • us2ms

      public static long us2ms(long microseconds)
      Converts Microseconds to Milliseconds
      Parameters:
      microseconds - Time in microseconds
      Returns:
      Milliseconds
    • us2s

      public static long us2s(long microseconds)
      Converts Microseconds to Seconds
      Parameters:
      microseconds - Time in microseconds
      Returns:
      Seconds
    • ms2s

      public static long ms2s(long milliseconds)
      Converts Milliseconds to Seconds
      Parameters:
      milliseconds - Time in milliseconds
      Returns:
      Seconds
    • ns2ms

      public static long ns2ms(long nanoseconds)
      Converts Nanoseconds to Milliseconds
      Parameters:
      nanoseconds - Time in nanoseconds
      Returns:
      Milliseconds