Package com.castlabs.utils
Class TimeUtils
java.lang.Object
com.castlabs.utils.TimeUtils
Utilities around time
- Since:
- 3.3.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
ms2s
(long milliseconds) Converts Milliseconds to Secondsstatic long
ms2us
(long milliseconds) Converts Milliseconds to Microsecondsstatic long
ns2ms
(long nanoseconds) Converts Nanoseconds to Millisecondsstatic long
s2ms
(double seconds) Converts Seconds (double) to Milliseconds (long) e.g.static long
s2ms
(long seconds) Converts Seconds to Millisecondsstatic long
s2us
(double seconds) Converts Seconds (double) to Microseconds (long) e.g.static long
s2us
(long seconds) Converts Seconds to Microsecondsstatic long
timeToMilliseconds
(String input) 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 Millisecondsstatic long
us2s
(long microseconds) Converts Microseconds to Seconds
-
Constructor Details
-
TimeUtils
public TimeUtils()
-
-
Method Details
-
timeToMilliseconds
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
-