@Extensibility(value=FINAL_EXTENSIBILITY) @Nested public abstract class Time extends Object implements Comparable<Time>, Serializable, DDSObject
Constructor and Description |
---|
Time() |
Modifier and Type | Method and Description |
---|---|
abstract long |
getRemainder(TimeUnit primaryUnit,
TimeUnit remainderUnit)
If getting the magnitude of this time in the given
primaryUnit would cause truncation with respect to the
given remainderUnit , return the magnitude of the
truncation in the latter (presumably finer-grained) unit. |
abstract long |
getTime(TimeUnit inThisUnit)
Truncate this time to a whole-number quantity of the given time
unit.
|
static Time |
invalidTime(ServiceEnvironment env) |
abstract boolean |
isValid() |
abstract ModifiableTime |
modifiableCopy() |
static ModifiableTime |
newTime(long time,
TimeUnit units,
ServiceEnvironment env)
Construct a specific instant in time.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compareTo
getEnvironment
public static ModifiableTime newTime(long time, TimeUnit units, ServiceEnvironment env)
t
such that:
t.isValid() == false
env
- Identifies the Service instance to which the new
object will belong.isValid()
public static Time invalidTime(ServiceEnvironment env)
env
- Identifies the Service instance to which the
object will belong.Time
that is not valid.public abstract long getTime(TimeUnit inThisUnit)
TimeUnit.SECONDS
will result in the value
1
.
If this time is invalid, this method shall return
a negative value, regardless of the units given.
If this time cannot be expressed in the given units without
overflowing, this method shall return Long.MAX_VALUE
. In such
a case, the caller may wish to use this method in combination with
getRemainder(TimeUnit, TimeUnit)
to obtain the full time
without lack of precision.inThisUnit
- The time unit in which the return result will
be measured.getRemainder(TimeUnit, TimeUnit)
,
Long.MAX_VALUE
,
TimeUnit
public abstract long getRemainder(TimeUnit primaryUnit, TimeUnit remainderUnit)
primaryUnit
would cause truncation with respect to the
given remainderUnit
, return the magnitude of the
truncation in the latter (presumably finer-grained) unit. For example,
if this time is equal to one second plus 100 nanoseconds since the
start of the epoch, calling this method with arguments of
TimeUnit.SECONDS
and TimeUnit.NANOSECONDS
respectively
will result in the value 100
.
This method is equivalent to the following pseudo-code:
(this - getTime(primaryUnit)).getTime(remainderUnit)
If remainderUnit
is represents a coarser granularity than
primaryUnit
(for example, the former is
TimeUnit.HOURS
but the latter is TimeUnit.SECONDS
),
this method shall return 0
.
If the resulting time cannot be expressed in the given units
without overflowing, this method shall return Long.MAX_VALUE
.primaryUnit
- remainderUnit
- The time unit in which the return result will
be measured.getTime(TimeUnit)
,
Long.MAX_VALUE
,
TimeUnit
public abstract boolean isValid()
public abstract ModifiableTime modifiableCopy()
Copyright © 2014. All rights reserved.