public class RelativeTime extends HighResolutionTime<RelativeTime>
An instance of this class represents an interval of time measured by a Chronograph. The interval is given as a tuple of milliseconds and nanoseconds. The set of intervals that can be represented by this class ranges from -263ms - 999,999ns to 263ms - 1ns (more than 292 billion years back and into the future).
Constructor and Description |
---|
RelativeTime()
Constructor to create the empty interval bound to the default
RealtimeClock.
|
RelativeTime(Chronograph chronograph)
Constructor to create the empty interval bound to the provided
chronograph.
|
RelativeTime(Clock clock)
Deprecated.
since version 2.0
|
RelativeTime(long ms,
int ns)
Constructor to create an interval using the provided interval
that is bound to the default RealtimeClock.
|
RelativeTime(long ms,
int ns,
Chronograph chronograph)
Constructor to create an interval using the provided interval
that is bound to the default RealtimeClock.
|
RelativeTime(long ms,
int ns,
Clock clock)
Deprecated.
since version 2.0
|
RelativeTime(RelativeTime time)
Constructor to create a new RelativeTime object that represents
the same interval as the given RelativeTime and that has the same
chronograph association.
|
RelativeTime(RelativeTime time,
Chronograph chronograph)
Constructor to create a new RelativeTime object that represents
the same interval as the given RelativeTime and that has the same
chronograph association or the chronograph association provided
as the clock parameter.
|
RelativeTime(RelativeTime time,
Clock clock)
Deprecated.
since version 2.0
|
Modifier and Type | Method and Description |
---|---|
AbsoluteTime |
absolute(Chronograph chronograph)
absolute creates a new instance of absolute time for the point in
time given by the current time of the given chronograph.
|
AbsoluteTime |
absolute(Chronograph chronograph,
AbsoluteTime destination)
absolute converts this relative time into an instance of absolute
time for the point in time given by the current time of the given
chronograph.
|
AbsoluteTime |
absolute(Clock clock)
Deprecated.
since RTSJ 2.0
|
AbsoluteTime |
absolute(Clock clock,
AbsoluteTime destination)
Deprecated.
since RTSJ 2.0
|
RelativeTime |
add(long millis,
int nanos)
add adds time given in milliseconds and nanoseconds to this
relative time.
|
RelativeTime |
add(long millis,
int nanos,
RelativeTime dest)
add adds time given in milliseconds and nanoseconds to this
relative time.
|
RelativeTime |
add(RelativeTime time)
add adds interval given as an instance of RelativeTime to this
relative time.
|
RelativeTime |
add(RelativeTime time,
RelativeTime dest)
add adds interval given as an instance of RelativeTime to this
relative time.
|
void |
addInterarrivalTo(AbsoluteTime destination)
Deprecated.
RTSJ V1.0.1 this method is only required to support
the deprecated RationalTime.
|
RelativeTime |
apportion(int factor)
multiply the current time by an integral scaling factor.
|
RelativeTime |
apportion(int factor,
RelativeTime destination)
Divide the current time by an integral factor.
|
int |
compareToZero()
compareTo compares this to zero.
|
RelativeTime |
getInterarrivalTime()
Deprecated.
RTSJ V1.0.1 this method is only required to support
the deprecated RationalTime.
|
RelativeTime |
getInterarrivalTime(RelativeTime dest)
Deprecated.
RTSJ V1.0.1 this method is only required to support
the deprecated RationalTime.
|
RelativeTime |
multiply(float factor,
RelativeTime dest)
Multiply this relative time by a floating point factor.
|
RelativeTime |
negate()
Multiply the current time by -1.
|
RelativeTime |
negate(RelativeTime destination)
Multiply the current time by -1.
|
RelativeTime |
relative(Chronograph chronograph)
relative returns a new instance of this interval with the given
chronograph association.
|
RelativeTime |
relative(Chronograph chronograph,
RelativeTime destination)
relative returns a copy of this interval with the given chronograph
association.
|
RelativeTime |
relative(Clock clock)
Deprecated.
since RTSJ 2.0
|
RelativeTime |
relative(Clock clock,
RelativeTime destination)
Deprecated.
since RTSJ 2.0
|
RelativeTime |
scale(int factor)
multiply the current time by an integral scaling factor.
|
RelativeTime |
scale(int factor,
RelativeTime destination)
Multiply the current time by an integral factor.
|
RelativeTime |
subtract(RelativeTime time)
substract substracts interval given as an instance of
RelativeTime from this relative time.
|
RelativeTime |
subtract(RelativeTime time,
RelativeTime dest)
Subtracts time from this.
|
String |
toString()
toString returns this interval as a string of the form
"(<milli>ms, <nano> ns)".
|
clone, compareTo, equals, equals, getChronograph, getClock, getMilliseconds, getNanoseconds, hashCode, set, set, set, set, waitForObject
public RelativeTime()
This constructor is equivalent to RelativeTime(0, 0).
public RelativeTime(long ms, int ns)
Constructor to create an interval using the provided interval that is bound to the default RealtimeClock.
This constructor is equivalent to RelativeTime(ms, ns, null).
StaticIllegalArgumentException
- if normalization of millis and
nanos caused an overflow.ms
- the milliseconds part of the intervalns
- the nanoseconds part of the interval.public RelativeTime(RelativeTime time)
time
- the original RelativeTime.
+ @throws StaticIllegalArgumentException if time is null.public RelativeTime(Chronograph chronograph)
This constructor is equivalent to RelativeTime(0, 0, chronograph).
chronograph
- the chronograph to be associated with this time,
null to use Clock.getRealtimeClock().@Deprecated public RelativeTime(Clock clock)
This constructor is equivalent to RelativeTime(0, 0, clock).
clock
- the clock to be associated with this time,
null to use Clock.getRealtimeClock().public RelativeTime(long ms, int ns, Chronograph chronograph)
StaticIllegalArgumentException
- if normalization of millis and
nanos caused an overflow.ms
- the milliseconds part of the intervalns
- the nanoseconds part of the interval.chronograph
- the chronograph to be associated with this time,
null to use Clock.getRealtimeClock().@Deprecated public RelativeTime(long ms, int ns, Clock clock)
StaticIllegalArgumentException
- if normalization of millis and
nanos caused an overflow.ms
- the milliseconds part of the intervalns
- the nanoseconds part of the interval.clock
- the clock to be associated with this time,
null to use Clock.getRealtimeClock().public RelativeTime(RelativeTime time, Chronograph chronograph)
StaticIllegalArgumentException
- if time is null.time
- the original RelativeTime.chronograph
- the chronograph association. May be null to use
time.getChronograph().@Deprecated public RelativeTime(RelativeTime time, Clock clock)
StaticIllegalArgumentException
- if time is null.time
- the original RelativeTime.clock
- the clock association. May be null to use
time.getChronograph().public AbsoluteTime absolute(Chronograph chronograph, AbsoluteTime destination)
absolute
in class HighResolutionTime<RelativeTime>
ArithmeticException
- if the resulting absolute time could
not be represented by an instance of AbsoluteTime.chronograph
- The chronograph, null to use Clock.getRealtimeClock().destination
- the destination absolute time object.@Deprecated public AbsoluteTime absolute(Clock clock, AbsoluteTime destination)
absolute
in class HighResolutionTime<RelativeTime>
ArithmeticException
- if the resulting absolute time could
not be represented by an instance of AbsoluteTime.clock
- The clock, null to use Clock.getRealtimeClock().destination
- the destination absolute time object.public AbsoluteTime absolute(Chronograph chronograph)
absolute
in class HighResolutionTime<RelativeTime>
ArithmeticException
- if the resulting absolute time could
not be represented by an instance of AbsoluteTime.chronograph
- The chronograph, null to use Clock.getRealtimeClock().@Deprecated public AbsoluteTime absolute(Clock clock)
absolute
in class HighResolutionTime<RelativeTime>
ArithmeticException
- if the resulting absolute time could
not be represented by an instance of AbsoluteTime.clock
- The clock, null to use Clock.getRealtimeClock().public RelativeTime relative(Chronograph chronograph)
relative
in class HighResolutionTime<RelativeTime>
chronograph
- The chronograph, null to use Clock.getRealtimeClock().@Deprecated public RelativeTime relative(Clock clock)
relative
in class HighResolutionTime<RelativeTime>
clock
- The clock, null to use Clock.getRealtimeClock().public RelativeTime relative(Chronograph chronograph, RelativeTime destination)
relative
in class HighResolutionTime<RelativeTime>
chronograph
- The chronograph, null to use Clock.getRealtimeClock().destination
- the destination relative time object.@Deprecated public RelativeTime relative(Clock clock, RelativeTime destination)
relative
in class HighResolutionTime<RelativeTime>
clock
- The clock, null to use Clock.getRealtimeClock().destination
- the destination relative time object.public RelativeTime add(long millis, int nanos)
ArithmeticException
- if the addition or normalization
results in an overflow.millis
- the milliseconds part of the interval to be added.nanos
- the nanoseconds part of the interval to be added.public int compareToZero()
public RelativeTime negate(RelativeTime destination)
scale(int, RelativeTime)
, where scale is given as -1; however
it is much faster.ArithmeticException
- when the negation results in an overflow.destination
- the destination relative time object.public RelativeTime negate()
scale(int)
, where scale is given as -1; however
it is much faster.ArithmeticException
- when the negation results in an overflow.public RelativeTime scale(int factor, RelativeTime destination)
ArithmeticException
- when the scaling results in an overflow.StaticIllegalArgumentException
- when factor
is
negative.factor
- by which to scale this time, which must not be
negative.destination
- the destination relative time object.public RelativeTime scale(int factor)
ArithmeticException
- when the scaling results in an overflow.factor
- by which to scale this time.public RelativeTime apportion(int factor, RelativeTime destination)
StaticIllegalArgumentException
- when factor
is
zero or negative.factor
- by which to divide this time, which must be greater
than zero.destination
- the destination relative time object.public RelativeTime apportion(int factor)
ArithmeticException
- when the scaling results in an overflow.factor
- by which to apportion this time.public RelativeTime add(long millis, int nanos, RelativeTime dest)
ArithmeticException
- if the addition or normalization
results in an overflow.millis
- the milliseconds part of the interval to be added.nanos
- the nanoseconds part of the interval to be added.dest
- The preallocated RelativeTime object to hold the
result. May be null to indicate that a new object should be
allocated.public RelativeTime add(RelativeTime time)
ArithmeticException
- if the addition or normalization
results in an overflow.StaticIllegalArgumentException
- if time is null or
time.getChronograph() != getChronograph().time
- the time to be added.public RelativeTime add(RelativeTime time, RelativeTime dest)
ArithmeticException
- if the addition or normalization
results in an overflow.StaticIllegalArgumentException
- if time is null or
time.getChronograph() != getChronograph().time
- the time to be added.dest
- The preallocated RelativeTime object to hold the
result. May be null to indicate that a new object should be
allocated.@Deprecated public void addInterarrivalTo(AbsoluteTime destination) throws NullPointerException
NullPointerException
destination
- @Deprecated public RelativeTime getInterarrivalTime()
@Deprecated public RelativeTime getInterarrivalTime(RelativeTime dest)
dest
- The preallocated RelativeTime object to hold the
result. May be null to indicate that a new object should be
allocated.public RelativeTime subtract(RelativeTime time)
ArithmeticException
- if the subsctraction or normalization
results in an overflow.time
- the time to be added.public RelativeTime subtract(RelativeTime time, RelativeTime dest)
ArithmeticException
- if the subtraction or normalization
results in an overflow.StaticIllegalArgumentException
- if time is null or
time.getChronograph() != getChronograph().time
- the time to be subtracted.dest
- The preallocated RelativeTime object to hold the
result. May be null to indicate that a new object should be
allocated.public RelativeTime multiply(float factor, RelativeTime dest)
factor
- the factor by which to multiply.dest
- an object into which to place the result.dest
, when not null
, or a new object
holding the result.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2025 aicas GmbH. All Rights Reserved.