public class Duration extends TimeBase implements java.lang.Comparable<Duration>
Can be added to PointInTime
objects or other Duration
objects. For the generation of new Duration
objects, double values
are parsed to the internal representation using long values. The method
Math.round(double)
is used to get the best fitting long value.
TimeBase.InvalidTimeBaseException
Modifier and Type | Field and Description |
---|---|
static Duration |
ZERO |
EXPORT_UNIT, EXPORT_VALUE
CREATE_INSTANCE_METHOD_NAME
Modifier | Constructor and Description |
---|---|
protected |
Duration(long value)
Does not need to be positive
|
|
Duration(PointInTime first,
PointInTime second)
This method returns the duration between two
PointInTime objects.Be aware: this method assumes ordered arguments and may return negative durations! The result is positive if and only if second.isLaterThan(first). |
Modifier and Type | Method and Description |
---|---|
static Duration |
calculateSumOf(java.util.Collection<Duration> durations) |
int |
compareTo(Duration other) |
static Duration |
createInstance(SimNode ownNode,
Parameters pars) |
static Duration |
from(double value,
TimeUnits unit) |
static Duration |
fromDays(double days) |
static Duration |
fromHours(double hours) |
static Duration |
fromMicroSeconds(double microSeconds) |
static Duration |
fromMilliSeconds(double milliSeconds) |
static Duration |
fromMinutes(double minutes) |
static Duration |
fromNanoSeconds(double nanoSeconds) |
static Duration |
fromPicoSeconds(double picoSeconds) |
static Duration |
fromSeconds(double seconds) |
static Duration |
importBatch(ResultReader reader,
java.lang.String name) |
boolean |
isGreaterThan(Duration other) |
boolean |
isGreaterThanOrEqualTo(Duration other) |
boolean |
isLessThan(Duration other) |
boolean |
isLessThanOrEqualTo(Duration other) |
Duration |
multiplyBy(double scale) |
Duration |
multiplyBy(long scale) |
Duration |
negated() |
Duration |
plus(Duration other) |
double |
ratio(Duration other)
This method is to answer the relation of two durations, e.g.
|
Duration |
selectLonger(Duration other)
Return the longer of two durations.
|
Duration |
selectShorter(Duration other)
Return the shorter of two durations
|
changeTimeBase, changeTimeBase, equals, exportBatch, getTimeUnit, getValue, hashCode, internalToSeconds, secondsToInternal, toDays, toHours, toMicroSeconds, toMilliSeconds, toMinutes, toNanoSeconds, toPicoSeconds, toSeconds, toString, toString, toString
public static Duration ZERO
protected Duration(long value)
public Duration(PointInTime first, PointInTime second)
PointInTime
objects.first
- typically the earlier PointInTime
second
- typically the later PointInTime
public static Duration createInstance(SimNode ownNode, Parameters pars)
public static Duration fromDays(double days)
public static Duration fromHours(double hours)
public static Duration fromMinutes(double minutes)
public static Duration fromSeconds(double seconds)
public static Duration fromMilliSeconds(double milliSeconds)
public static Duration fromMicroSeconds(double microSeconds)
public static Duration fromNanoSeconds(double nanoSeconds)
public static Duration fromPicoSeconds(double picoSeconds)
public static Duration importBatch(ResultReader reader, java.lang.String name) throws ImportException
ImportException
public double ratio(Duration other)
other
- divisor of the fractionpublic Duration multiplyBy(long scale)
public Duration multiplyBy(double scale)
public Duration negated()
public int compareTo(Duration other)
compareTo
in interface java.lang.Comparable<Duration>
public boolean isGreaterThan(Duration other)
public boolean isGreaterThanOrEqualTo(Duration other)
public boolean isLessThan(Duration other)
public boolean isLessThanOrEqualTo(Duration other)
public Duration selectLonger(Duration other)
other
- the other value