-
- All Implemented Interfaces:
-
java.lang.Comparable
public class Duration implements Comparable<Duration>
Replacement for Java duration class which has only been introduced in SDK 26
-
-
Method Summary
Modifier and Type Method Description static Duration
ofNanos(long nanoSeconds)
Returns a new Duration object based on amount of nanoseconds. static Duration
ofMillis(long milliSeconds)
Returns a new Duration object based on amount of milliseconds. static Duration
ofMillis(double milliSeconds)
Returns a new Duration object based on amount of fractional milliseconds. long
toNanos()
Returns the amount of nanoseconds in this duration. int
toMillis()
Returns the amount of milliseconds in this duration. double
toMillisFractional()
Returns the amount of milliseconds in this duration. int
compareTo(Duration duration)
Compares 2 duration objects. -
-
Method Detail
-
ofNanos
static Duration ofNanos(long nanoSeconds)
Returns a new Duration object based on amount of nanoseconds.
- Parameters:
nanoSeconds
- duration in nanoseconds.
-
ofMillis
static Duration ofMillis(long milliSeconds)
Returns a new Duration object based on amount of milliseconds.
- Parameters:
milliSeconds
- duration in milliseconds.
-
ofMillis
static Duration ofMillis(double milliSeconds)
Returns a new Duration object based on amount of fractional milliseconds.
- Parameters:
milliSeconds
- duration in milliseconds.
-
toNanos
long toNanos()
Returns the amount of nanoseconds in this duration.
-
toMillis
int toMillis()
Returns the amount of milliseconds in this duration.
-
toMillisFractional
double toMillisFractional()
Returns the amount of milliseconds in this duration.
-
-
-
-