aicas logoJamaica 6.1 release 1

javax.realtime
Class AbsoluteTime

java.lang.Object
  extended by javax.realtime.HighResolutionTime
      extended by javax.realtime.AbsoluteTime
All Implemented Interfaces:
Cloneable, Comparable<Object>

public class AbsoluteTime
extends HighResolutionTime

Jamaica Real-Time Specification for Java class AbsoluteTime.

This class represents an absolute point in the time represented by a Clock.


Constructor Summary
AbsoluteTime()
          Constructor to create absolute time 0ms, 0ns.
AbsoluteTime(AbsoluteTime time)
          Constructor to create an absolute time with millis and nanos taken from an existing absolute time.
AbsoluteTime(AbsoluteTime time, Clock clock)
          Constructor to create an absolute time with millis and nanos taken from an existing absolute time.
AbsoluteTime(Clock clock)
          Constructor to create absolute time 0ms, 0ns with given clock association.
AbsoluteTime(Date date)
          Constructor to create an absolute time from a time represented by an instance of Date.
AbsoluteTime(Date date, Clock clock)
          Constructor to create an absolute time from a time represented by an instance of Date.
AbsoluteTime(long millis, int nanos)
          Constructor to create an absolute time from given milli and nano seconds.
AbsoluteTime(long millis, int nanos, Clock clock)
          Constructor to create an absolute time from given milli and nano seconds.
 
Method Summary
 AbsoluteTime absolute(Clock clock)
          absolute implements abstract method inherited from HighResolutionTime.
 AbsoluteTime absolute(Clock clock, AbsoluteTime dest)
          absolute implements abstract method inherited from HighResolutionTime.
 AbsoluteTime add(long millis, int nanos)
          add adds time given in milliseconds and nanoseconds to this absolute time.
 AbsoluteTime add(long millis, int nanos, AbsoluteTime dest)
          add adds time given in milliseconds and nanoseconds to this absolute time.
 AbsoluteTime add(RelativeTime time)
          add adds interval given as RelativeTime instance to this absolute time.
 AbsoluteTime add(RelativeTime time, AbsoluteTime dest)
          add adds interval given as RelativeTime instance to this absolute time.
 Date getDate()
          getDate converts this absolute time to an instance of Date that represents the same time.
 RelativeTime relative(Clock clock)
          relative implements abstract method inherited from HighResolutionTime.
 RelativeTime relative(Clock clock, RelativeTime dest)
          relative implements abstract method inherited from HighResolutionTime.
 void set(Date date)
          set sets the time represented by this to the time represented by an instance of Date.
 RelativeTime subtract(AbsoluteTime time)
          subtract subtracts another absolute time from this absolute time.
 RelativeTime subtract(AbsoluteTime time, RelativeTime dest)
          subtract subtracts another absolute time from this absolute time.
 AbsoluteTime subtract(RelativeTime time)
          subtract subtracts an interval given as an instance of RelativeTime from this.
 AbsoluteTime subtract(RelativeTime time, AbsoluteTime dest)
          subtract subtracts an interval given as an instance of RelativeTime from this.
 String toString()
          toString converts this to a String
 
Methods inherited from class javax.realtime.HighResolutionTime
clone, compareTo, compareTo, equals, equals, getClock, getMilliseconds, getNanoseconds, hashCode, set, set, set, waitForObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbsoluteTime

public AbsoluteTime()
Constructor to create absolute time 0ms, 0ns.


AbsoluteTime

public AbsoluteTime(AbsoluteTime time)
Constructor to create an absolute time with millis and nanos taken from an existing absolute time. Use time.getClock() as associated clock.

Parameters:
time - the original absolute time, must not be null.

AbsoluteTime

public AbsoluteTime(Date date)
Constructor to create an absolute time from a time represented by an instance of Date. Use the RealtimeClock as associated clock.

Parameters:
date - the original Date, must not be null.

AbsoluteTime

public AbsoluteTime(long millis,
                    int nanos)
Constructor to create an absolute time from given milli and nano seconds. nanos should be positive.

ensure

   (this.getMilliseconds() == millis,
    this.getNanosecondes() == nanos);
 

Parameters:
millis - the milliseconds value for the new absolute time.
nanos - the nanoseconds value for the new absolute time.

AbsoluteTime

public AbsoluteTime(Clock clock)
Constructor to create absolute time 0ms, 0ns with given clock association.

Parameters:
clock - the clock to be associated with this time, Clock.getRealtimeClock if null.

AbsoluteTime

public AbsoluteTime(AbsoluteTime time,
                    Clock clock)
Constructor to create an absolute time with millis and nanos taken from an existing absolute time. Use given clock association.

Parameters:
time - the original absolute time, must not be null.
clock - the clock to be associated with this time, Clock.getRealtimeClock if null.

AbsoluteTime

public AbsoluteTime(Date date,
                    Clock clock)
Constructor to create an absolute time from a time represented by an instance of Date. Use given clock association.

Parameters:
date - the original Date, must not be null.
clock - the clock to be associated with this time, Clock.getRealtimeClock if null.

AbsoluteTime

public AbsoluteTime(long millis,
                    int nanos,
                    Clock clock)
Constructor to create an absolute time from given milli and nano seconds. nanos should be positive. Use given clock association.

ensure

   (this.getMilliseconds() == millis,
    this.getNanosecondes() == nanos);
 

Parameters:
millis - the milliseconds value for the new absolute time.
nanos - the nanoseconds value for the new absolute time.
clock - the clock to be associated with this time, Clock.getRealtimeClock if null.
Method Detail

absolute

public AbsoluteTime absolute(Clock clock,
                             AbsoluteTime dest)
absolute implements abstract method inherited from HighResolutionTime. It converts this time to an absolute time relative to the given clock. Use a preallocated AbsoluteTime object if present.

For AbsoluteTime, the result is this iff dest is null.

Specified by:
absolute in class HighResolutionTime
Parameters:
clock - The clock the result should be relative to.
dest - The preallocated AbsoluteTime object to hold the result. May be null to indicate that a new object should be allocated.
Returns:
dest, if dest is not null, this otherwise.

absolute

public AbsoluteTime absolute(Clock clock)
absolute implements abstract method inherited from HighResolutionTime. absolute converts this time to an absolute time relative to the given clock.

For AbsoluteTime, the result is this iff dest is null.

Specified by:
absolute in class HighResolutionTime
Parameters:
clock - The clock the result should be relative to.
Returns:
this or a new object allocated from the current memory area for the absolute time.

add

public AbsoluteTime add(long millis,
                        int nanos)
add adds time given in milliseconds and nanoseconds to this absolute time.

Parameters:
millis - the milliseconds part of the interval to be added.
nanos - the nanoseconds part of the interval to be added.
Returns:
a new instance of AbsoluteTime of the time of this plus the interval millis/nanos.

add

public AbsoluteTime add(long millis,
                        int nanos,
                        AbsoluteTime dest)
add adds time given in milliseconds and nanoseconds to this absolute time.

Parameters:
millis - the milliseconds part of the interval to be added.
nanos - the nanoseconds part of the interval to be added.
dest - The preallocated AbsoluteTime object to hold the result. May be null to indicate that a new object should be allocated.
Returns:
dest, if dest is not null, the newly allocated object otherwise. The result represents that absolute time of this plus the interval millis/nanos.

add

public AbsoluteTime add(RelativeTime time)
add adds interval given as RelativeTime instance to this absolute time.

Parameters:
time - the interval to be added
Returns:
a new instance of AbsoluteTime of the time of this plus the interval time.

add

public AbsoluteTime add(RelativeTime time,
                        AbsoluteTime dest)
add adds interval given as RelativeTime instance to this absolute time.

Parameters:
time - the interval to be added
dest - The preallocated AbsoluteTime object to hold the result. May be null to indicate that a new object should be allocated.
Returns:
dest, if dest is not null, the newly allocated object otherwise. The result represents that absolute time of this plus the interval time.

getDate

public Date getDate()
getDate converts this absolute time to an instance of Date that represents the same time. Precision is lost in this conversion, the precision of Data is restricted to milliseconds.

Returns:
a new instance of Date.

set

public void set(Date date)
set sets the time represented by this to the time represented by an instance of Date.

Parameters:
date - an instance of Date, must not be null.

subtract

public RelativeTime subtract(AbsoluteTime time)
subtract subtracts another absolute time from this absolute time.

Parameters:
time - the other absolute time.
Returns:
a new instance of RelativeTime of the length of the interval between this and time.

subtract

public RelativeTime subtract(AbsoluteTime time,
                             RelativeTime dest)
subtract subtracts another absolute time from this absolute time.

Parameters:
time - the other absolute time.
dest - The preallocated RelativeTime object to hold the result. May be null to indicate that a new object should be allocated.
Returns:
dest, if dest is not null, the newly allocated object otherwise. The result represents the interval between this and time.

subtract

public AbsoluteTime subtract(RelativeTime time)
subtract subtracts an interval given as an instance of RelativeTime from this.

Parameters:
time - the interval to be subtracted.
Returns:
a new instance of AbsoluteTime of the time of this minus the interval time.

subtract

public AbsoluteTime subtract(RelativeTime time,
                             AbsoluteTime dest)
subtract subtracts an interval given as an instance of RelativeTime from this.

Parameters:
time - the interval to be subtracted.
dest - The preallocated RelativeTime object to hold the result. May be null to indicate that a new object should be allocated.
Returns:
dest, if dest is not null, the newly allocated object otherwise. The result represents the absolute time of this minus the interval time.

toString

public String toString()
toString converts this to a String

Overrides:
toString in class Object
Returns:
getDate().toString() + " " + millis % 1000 + "ms " + nanos + "ns"

relative

public RelativeTime relative(Clock clock)
relative implements abstract method inherited from HighResolutionTime. relative returns a new relative time object for this relative to the given clock.

Specified by:
relative in class HighResolutionTime
Parameters:
clock - The clock the result should be relative to.
Returns:
a new RelativeTime object.

relative

public RelativeTime relative(Clock clock,
                             RelativeTime dest)
relative implements abstract method inherited from HighResolutionTime. relative returns a new relative time object for this relative to the given clock.

Specified by:
relative in class HighResolutionTime
Parameters:
clock - The clock the result should be relative to.
dest - The preallocated RelativeTime object to hold the result. May be null to indicate that a new object should be allocated.
Returns:
time, if time is not null, the newly allocated object otherwise.

aicas logoJamaica 6.1 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2012 aicas GmbH. All Rights Reserved.