public final class TimeSpan extends java.lang.Object implements java.lang.Comparable<TimeSpan>
Modifier and Type | Class and Description |
---|---|
static class |
TimeSpan.Builder
Use the Builder to create TimeSpans specified as the sum of durations
with different TimeUnits Example (timeSpan with the length of one hour
and 30 minutes): new TimeSpan.Builder().hours(1).minutes(30).build();
|
Constructor and Description |
---|
TimeSpan(double duration)
Constructs a TimeSpan object with the given time value in the time unit
of the reference time.
|
TimeSpan(double duration,
java.util.concurrent.TimeUnit unit)
Constructs a TimeSpan object with the given time value in the given
timeUnit.
|
TimeSpan(long duration)
Constructs a TimeSpan object with the given time value in the time unit
of the reference time.
|
TimeSpan(long duration,
java.util.concurrent.TimeUnit unit)
Constructs a TimeSpan object with the given time value in the time unit
of the given parameter.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(TimeSpan anotherTimeSpan)
Compares the given TimeSpan to this TimeSpan.
|
boolean |
equals(java.lang.Object obj)
Indicates whether this TimeSpan is equal to the given parameter.
|
double |
getTimeAsDouble()
Returns the value of this TimeSpan object as a double type in the time unit
of the reference time.
|
double |
getTimeAsDouble(java.util.concurrent.TimeUnit unit)
Returns the value of this TimeSpan object as a double type in the time unit
given as a parameter.
|
long |
getTimeInEpsilon()
Returns the value of the TimeSpan object as a long type in the time unit
of epsilon
|
long |
getTimeRounded()
Returns the value of this TimeSpan object as a long type in the time unit
of the reference time.
|
long |
getTimeRounded(java.util.concurrent.TimeUnit unit)
Returns the value of this TimeSpan object as a long type in the time unit
given as a parameter.
|
long |
getTimeTruncated()
Returns the value of this TimeSpan object as a long type in the time unit
of the reference time.
|
long |
getTimeTruncated(java.util.concurrent.TimeUnit unit)
Returns the value of this TimeSpan object as a long type in the time unit
given as a parameter.
|
int |
hashCode()
Returns a hash code value for the object.
|
static boolean |
isEqual(TimeSpan a,
TimeSpan b)
Indicates whether TimeSpan a is equal to TimeSpan b, i.e. they are of
equal length.
|
static boolean |
isLonger(TimeSpan a,
TimeSpan b)
Checks if the first of two spans of simulation time is longer than the
second.
|
static boolean |
isLongerOrEqual(TimeSpan a,
TimeSpan b)
Checks if the first of two spans of simulation time is longer than the
second or equal to the second.
|
static boolean |
isShorter(TimeSpan a,
TimeSpan b)
Checks if the first of two spans of simulation time is shorter than the
second.
|
static boolean |
isShorterOrEqual(TimeSpan a,
TimeSpan b)
Checks if the first of two spans of simulation time is shorter than the
second or equal to the second.
|
boolean |
isZero()
Indicates whether this TimeSpan is equal to 0.
|
java.lang.String |
toString()
Returns the String Representation of this TimeSpan.
|
java.lang.String |
toString(int digits)
Returns the String Representation of this TimeSpan according to the
TimeFormatter, truncating digits after the decimal point if necessary.
|
public TimeSpan(long duration, java.util.concurrent.TimeUnit unit)
duration
- long : The time value of this TimeSpanunit
- TimeUnit: the TimeUnitpublic TimeSpan(long duration)
duration
- long : The time value of this TimeSpan in the time unit of the
reference time.public TimeSpan(double duration, java.util.concurrent.TimeUnit unit)
duration
- double : The time value of this TimeSpan in the time unit of
the reference time.unit
- TimeUnit : the time unitpublic TimeSpan(double duration)
duration
- double : The time value of this TimeSpan in the time unit of
the reference time.public long getTimeInEpsilon()
public long getTimeTruncated(java.util.concurrent.TimeUnit unit)
unit
- : the TimeUnitpublic long getTimeTruncated()
public long getTimeRounded(java.util.concurrent.TimeUnit unit)
unit
- : the TimeUnitpublic long getTimeRounded()
public double getTimeAsDouble(java.util.concurrent.TimeUnit unit)
public double getTimeAsDouble()
public static boolean isLonger(TimeSpan a, TimeSpan b)
TimeSpan
i.e. TimeSpan.isLonger(a,b)
where a and b are valid TimeSpan objects.a
- TimeSpan : first comparandb
- TimeSpan : second comparandpublic static boolean isLongerOrEqual(TimeSpan a, TimeSpan b)
TimeSpan
i.e.
TimeSpan.isLonger(a,b)
where a and b are valid TimeSpan
objects.a
- TimeSpan : first comparandb
- TimeSpan : second comparandpublic static boolean isShorter(TimeSpan a, TimeSpan b)
TimeSpan
i.e. TimeSpan.isShorter(a,b)
where a and b are valid TimeSpan objects.a
- TimeSpan : first comparandb
- TimeSpan : second comparandpublic static boolean isShorterOrEqual(TimeSpan a, TimeSpan b)
TimeSpan
i.e.
TimeSpan.isShorterOrEqual(a,b)
where a and b are valid
TimeSpan objects.a
- TimeSpan : first comparandb
- TimeSpan : second comparandpublic static boolean isEqual(TimeSpan a, TimeSpan b)
a
- TimeSpan: first comparandb
- TimeSpan: second comparandpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the reference object with which to compare.public boolean isZero()
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(TimeSpan anotherTimeSpan)
compareTo
in interface java.lang.Comparable<TimeSpan>
anotherTimeSpan
- The TimeSpan to be compared to this TimeSpanpublic java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public java.lang.String toString(int digits)
digits
- Maximum number of digits after decimal pointObject.toString()
,
TimeFormatter