public class Duration extends Type<Long> implements Comparable<Duration>
Long
value.Timespan
,
Serialized FormModifier and Type | Field and Description |
---|---|
static Duration |
DAY |
static Duration |
HOUR |
static Duration |
MILLISECOND |
static Duration |
MINUTE |
static Duration |
SECOND |
Modifier and Type | Method and Description |
---|---|
Duration |
add(Duration addedDuration)
Returns a
Duration instance representing the sum of this duration and the
given duration. |
int |
compareTo(Duration other) |
Duration |
difference(Duration otherDuration)
Returns a
Duration instance representing the difference between this duration
and the given duration. |
static Duration |
fromMilliseconds(long milliseconds)
Creates a duration from the given millisecond value.
|
static Duration |
fromSeconds(long seconds)
Creates a duration from the given amount of seconds.
|
long |
inMilliseconds()
Returns the duration in milliseconds.
|
long |
inSeconds()
Returns the duration in completed seconds.
|
String |
toString()
Returns the duration in seconds as textual representation.
|
public static final Duration MILLISECOND
public static final Duration SECOND
public static final Duration MINUTE
public static final Duration HOUR
public static final Duration DAY
public static Duration fromMilliseconds(long milliseconds)
milliseconds
- the millisecond valuepublic static Duration fromSeconds(long seconds)
seconds
- The duration in seconds.ArithmeticException
- if the long data range overflows when converting
seconds to milliseconds.public final long inMilliseconds()
public final long inSeconds()
public final Duration add(Duration addedDuration)
Duration
instance representing the sum of this duration and the
given duration. The original instances are not modified.addedDuration
- Duration to be addedNullPointerException
- if addedDuration
is null
public final Duration difference(Duration otherDuration)
Duration
instance representing the difference between this duration
and the given duration. The original instances are not modified.otherDuration
- Duration to be comparedNullPointerException
- if otherDuration
is null
public String toString()
public int compareTo(Duration other)
compareTo
in interface Comparable<Duration>
Copyright © Aimpulse Intelligent Systems GmbH
All rights reserved.