|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.realtime.HighResolutionTime | +--javax.realtime.RelativeTime
An object that represents a time interval millis/1E3+nanos/1E9 seconds long. It generally is used to represent a time relative to now.
If the values of any of the millisecond or nanosecond fields is
negative the variable is set to negative value. Although logically,
and correctly, this may represent time before the epoch, invalid
results may occur if an instance of RelativeTime
representing time before the epoch is given as a paramter to some
method. For add
and subtract
negative values
behave just like they do in arithmetic.
Caution: This class is explicitly unsafe in multithreaded situations when it is being changed. No synchronization is done. It is assumed that users of this class who are mutating instances will be doing their own synchronization at a higher level
Field Summary | |
static javax.realtime.RelativeTime |
ZERO
|
Fields inherited from class javax.realtime.HighResolutionTime |
defaultClock |
Constructor Summary | |
RelativeTime()
Equivalent to new RelativeTime(0, 0) . |
|
RelativeTime(long millis,
int nanos)
Constructs a RelativeTime object representing an interval
defined by the given parameter values. |
|
RelativeTime(javax.realtime.RelativeTime t)
Make a new RelativeTime object from the given
RelativeTime object. |
Method Summary | |
javax.realtime.AbsoluteTime |
absolute(javax.realtime.Clock clock)
Convert the time given by this to an absolute time. |
javax.realtime.AbsoluteTime |
absolute(javax.realtime.Clock clock,
javax.realtime.AbsoluteTime destination)
Convert the time given by this to an absolute time. |
javax.realtime.RelativeTime |
add(long millis,
int nanos)
Add a specific number of milliseconds and nanoseconds to the appropriate fields of this . |
javax.realtime.RelativeTime |
add(long millis,
int nanos,
javax.realtime.RelativeTime destination)
Add a specific number of milliseconds and nanoseconds to the appropriate fields of this . |
javax.realtime.RelativeTime |
add(javax.realtime.RelativeTime time)
Add the interval of this to the interval of the given
instance of RelativeTime . |
javax.realtime.RelativeTime |
add(javax.realtime.RelativeTime time,
javax.realtime.RelativeTime destination)
Add the interval of this to the interval of the given
instance of RelativeTime . |
void |
addInterarrivalTo(javax.realtime.AbsoluteTime destination)
Add the interval of this to the given instance of
AbsoluteTime . |
javax.realtime.RelativeTime |
getInterarrivalTime()
Gets the interval defined by this . |
javax.realtime.RelativeTime |
getInterarrivalTime(javax.realtime.RelativeTime destination)
Gets the interval defined by this For an instance of
RelativeTime it is the interval divided by the frequency. |
javax.realtime.RelativeTime |
relative(javax.realtime.Clock clock)
Make a new RelativeTime object from the time given by
this but based on the given instance of Clock . |
javax.realtime.RelativeTime |
relative(javax.realtime.Clock clock,
javax.realtime.HighResolutionTime time)
Make a new RelativeTime object from the time given by
this but based on the given instance of Clock . |
javax.realtime.RelativeTime |
relative(javax.realtime.Clock clock,
javax.realtime.RelativeTime time)
Make a new RelativeTime object from the time given by
this but based on the given instance of Clock . |
javax.realtime.RelativeTime |
subtract(javax.realtime.RelativeTime time)
Subtract the interval defined by the given instance of RelativeTime from the interval defined by this . |
javax.realtime.RelativeTime |
subtract(javax.realtime.RelativeTime time,
javax.realtime.RelativeTime destination)
Subtract the interval defined by the given instance of RelativeTime from the interval defined by this . |
java.lang.String |
toString()
Return a printable version of the time defined by this . |
Methods inherited from class javax.realtime.HighResolutionTime |
compareTo, compareTo, equals, equals, getMilliseconds, getNanoseconds, hashCode, set, set, set, time, waitForObject |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static javax.realtime.RelativeTime ZERO
Constructor Detail |
public RelativeTime()
new RelativeTime(0, 0)
.
public RelativeTime(long millis, int nanos)
RelativeTime
object representing an interval
defined by the given parameter values.
millis
- The milliseconds component.nanos
- The nanoseconds component.public RelativeTime(javax.realtime.RelativeTime t)
RelativeTime
object from the given
RelativeTime
object.
t
- The RelativeTime
object used as the source
for the copy.Method Detail |
public javax.realtime.AbsoluteTime absolute(javax.realtime.Clock clock)
this
to an absolute time. The
calculation is the current time indicated by the given instance of
Clock
plus the interval given by this
.
absolute
in class HighResolutionTime
clock
- The given instance of Clock
If null,
Clock.getRealTimeClock()
is used.
AbsoluteTime
containing the result.public javax.realtime.AbsoluteTime absolute(javax.realtime.Clock clock, javax.realtime.AbsoluteTime destination)
this
to an absolute time. The
calculation is the current time indicated by the given instance of
Clock
plus the interval given by this
.
absolute
in class HighResolutionTime
clock
- The given instance of Clock
If null,
Clock.getRealTimeClock()
is used.destination
- A reference to the result instance of
AbsoluteTime
.
AbsoluteTime
containing the result.public javax.realtime.RelativeTime add(long millis, int nanos)
this
. A new object is allocated.
millis
- The number of milliseconds to add.nanos
- The number of nanoseconds to add.
public javax.realtime.RelativeTime add(long millis, int nanos, javax.realtime.RelativeTime destination)
this
. A new object is allocated.
millis
- The number of milliseconds to add.nanos
- The number of nanoseconds to add.destination
- A reference to the result instance of
RelativeTime
.
public final javax.realtime.RelativeTime add(javax.realtime.RelativeTime time)
this
to the interval of the given
instance of RelativeTime
.
time
- A reference to the given instance of RelativeTime
.
public javax.realtime.RelativeTime add(javax.realtime.RelativeTime time, javax.realtime.RelativeTime destination)
this
to the interval of the given
instance of RelativeTime
.
time
- A reference to the given instance of RelativeTime
.destination
- A reference to the result instance of RelativeTime
.
public void addInterarrivalTo(javax.realtime.AbsoluteTime destination)
this
to the given instance of
AbsoluteTime
.
destination
- A reference to the given instance of
AbsoluteTime
and the result.public javax.realtime.RelativeTime getInterarrivalTime()
this
. For an instance of
RationalTime
it is the interval divided by the frequency.
RelativeTime
with the same interval as this
.public javax.realtime.RelativeTime getInterarrivalTime(javax.realtime.RelativeTime destination)
this
For an instance of
RelativeTime
it is the interval divided by the frequency.
destination
- A reference to the new object holding the result.
public javax.realtime.RelativeTime relative(javax.realtime.Clock clock)
RelativeTime
object from the time given by
this
but based on the given instance of Clock
.
relative
in class HighResolutionTime
clock
- The given instance of Clock
.
RelativeTime
.public javax.realtime.RelativeTime relative(javax.realtime.Clock clock, javax.realtime.RelativeTime time)
RelativeTime
object from the time given by
this
but based on the given instance of Clock
.
clock
- The given instance of Clock
.time
- A reference to the result instance of RelativeTime
.
RelativeTime
.public javax.realtime.RelativeTime relative(javax.realtime.Clock clock, javax.realtime.HighResolutionTime time)
RelativeTime
object from the time given by
this
but based on the given instance of Clock
.
relative
in class HighResolutionTime
clock
- The given instance of Clock
.time
- A reference to the result instance of RelativeTime
.
HighResolutionTime
.public final javax.realtime.RelativeTime subtract(javax.realtime.RelativeTime time)
RelativeTime
from the interval defined by this
.
time
- A reference to the given instance of RelativeTime
.
public javax.realtime.RelativeTime subtract(javax.realtime.RelativeTime time, javax.realtime.RelativeTime destination)
RelativeTime
from the interval defined by this
.
time
- A reference to the given instance of RelativeTime
.destination
- A reference to the object holding the result.
public java.lang.String toString()
this
.
toString
in class java.lang.Object
java.lang.String
representing the
time defined by this
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |