@SCJAllowed public class RelativeTime extends HighResolutionTime
Clock is meaningless and ignored (RTSJ thinks otherwise).| Constructor and Description |
|---|
RelativeTime()
Equivalent to
RelativeTime(0,0). |
RelativeTime(Clock clock)
Constructs a duration of zero milliseconds and zero nanoseconds.
|
RelativeTime(long millis,
int nanos)
Construct a RelativeTime object representing a duration based on the parameter
millis
plus the parameter nanos. |
RelativeTime(long millis,
int nanos,
Clock clock)
Constructs a
RelativeTime object representing a duration based on the parameters. |
RelativeTime(RelativeTime time)
Makes a new
RelativeTime object from the given RelativeTime object. |
| Modifier and Type | Method and Description |
|---|---|
RelativeTime |
add(long millis,
int nanos)
Creates a new object representing the result of adding
millis and nanos to the values
from this and normalizing the result. |
RelativeTime |
add(long millis,
int nanos,
RelativeTime dest)
Returns an object containing the value resulting from adding
millis and nanos
to this and normalizing the result. |
RelativeTime |
add(RelativeTime time)
Creates a new object representing the result of adding
time to the value of this. |
RelativeTime |
add(RelativeTime time,
RelativeTime dest)
Returns an object containing the value resulting from adding
time to this
and normalizing the result. |
RelativeTime |
subtract(RelativeTime time)
Creates a new
RelativeTime object representing the result
of subtracting time from the value of this. |
RelativeTime |
subtract(RelativeTime time,
RelativeTime dest)
Creates a new
RelativeTime object representing the result
of subtracting time from the value of this. |
compareTo, equals, getClock, getMilliseconds, getNanoseconds, hashCode, set, set, set, toStringpublic RelativeTime()
RelativeTime(0,0).public RelativeTime(long millis,
int nanos)
millis
plus the parameter nanos. The construction is subject to normalization of these values.
millis - is the milliseconds.nanos - is the nanoseconds.public RelativeTime(Clock clock)
clock parameter.
If clock is null the association is made with the real-time clock.clock - is the clock argument.public RelativeTime(long millis,
int nanos,
Clock clock)
RelativeTime object representing a duration based on the parameters.
If clock is null the association is made with the real-time clock.millis - is the millisecondsnanos - is the nanosecondsclock - is the clockpublic RelativeTime(RelativeTime time)
RelativeTime object from the given RelativeTime object.time - is the copied object.java.lang.IllegalArgumentException - if time is null.public RelativeTime add(long millis, int nanos)
millis and nanos to the values
from this and normalizing the result. The result will have the same clock association as this.millis - is the milliseconds to be added.nanos - is the nanoseconds to be added.public RelativeTime add(RelativeTime time)
time to the value of this.time - is the duration to be added.java.lang.IllegalArgumentException - if time is null.java.lang.IllegalArgumentException - if the clock associated with this and the clock associated with
the time parameter are different.public RelativeTime add(long millis, int nanos, RelativeTime dest)
millis and nanos
to this and normalizing the result. If dest is not null, the result is
placed there and returned. Otherwise, a new object is allocated for the result.
The result will have the same clock association as this, and the clock association
of dest is ignored.millis - is the milliseconds to be added.nanos - is the nanoseconds to be added.dest - is the destination, if initially null a new RelativeTime() object is created.public RelativeTime add(RelativeTime time, RelativeTime dest)
time to this
and normalizing the result. If dest is not null, the result is placed there
and returned. Otherwise, a new object is allocated for the result. The clock associated with this
and the clock associated with the time parameter are expected to be the same, and
it is used for the result. The clock associated with the dest parameter is ignored.time - is the time to be addeddest - is the destination, if null a new RelativeTime() object is createdjava.lang.IllegalArgumentException - if time is null.java.lang.IllegalArgumentException - if the clock associated with this and the clock associated with
the time parameter are different.public RelativeTime subtract(RelativeTime time)
RelativeTime object representing the result
of subtracting time from the value of this.time - the value to be subtracted.java.lang.IllegalArgumentException - if time is null.java.lang.IllegalArgumentException - if the clock associated with this and the clock associated with
the time parameter are different.public RelativeTime subtract(RelativeTime time, RelativeTime dest)
RelativeTime object representing the result
of subtracting time from the value of this.
If dest is not null, the result is placed there and returned.
Otherwise, a new object is allocated for the result.
The clock associated with this and the clock associated with the time
parameter are expected to be the same, and such association is used for the result.
The clock associated with the dest parameter is ignored.time - is the duration to be subtracteddest - is the destination, if null a new RelativeTime() object is createddest object with the resulting value.java.lang.IllegalArgumentException - if time is null.java.lang.IllegalArgumentException - if the clock associated with this
and the clock associated with the time parameter are different.