lejos.realtime
Class AbsoluteTime

java.lang.Object
  extended by lejos.realtime.HighResolutionTime
      extended by lejos.realtime.AbsoluteTime

public class AbsoluteTime
extends HighResolutionTime

Author:
Team iRboT

Constructor Summary
AbsoluteTime()
          Equivalent to new AbsoluteTime(0,0).
AbsoluteTime(AbsoluteTime time)
          Make a new AbsoluteTime object from the given AbsoluteTime object.
AbsoluteTime(AbsoluteTime time, Clock clock)
          Make a new AbsoluteTime object from the given AbsoluteTime object.
AbsoluteTime(Clock clock)
          Equivalent to new AbsoluteTime(0,0,clock).
AbsoluteTime(Date date)
          Equivalent to new AbsoluteTime (date.getTime(),0).
AbsoluteTime(Date date, Clock clock)
          Equivalent to new AbsoluteTime (date.getTime(),0,clock).
AbsoluteTime(long millis, int nanos)
           
AbsoluteTime(long millis, int nanos, Clock clock)
           
 
Method Summary
 AbsoluteTime absolute(Clock clock)
          Convert the time of this to an absolute time, using the given instance of Clock to determine the current time when necessary.
 AbsoluteTime absolute(Clock clock, AbsoluteTime dest)
          Convert the time of this to an absolute time, using the given instance of Clock to determine the current time when necessary.
 AbsoluteTime add(long millis, int nanos)
           
 AbsoluteTime add(long millis, int nanos, AbsoluteTime dest)
           
 AbsoluteTime add(RelativeTime time)
           
 AbsoluteTime add(RelativeTime time, AbsoluteTime dest)
           
 Date getDate()
           
 RelativeTime relative(Clock clock)
          Convert the time of this to a relative time, using the given instance of Clock to determine the current time when necessary.
 RelativeTime relative(Clock clock, RelativeTime dest)
          Convert the time of this to a relative time, using the given instance of Clock to determine the current time when necessary.
 void set(Date date)
           
 RelativeTime subtract(AbsoluteTime time)
           
 RelativeTime subtract(AbsoluteTime time, RelativeTime dest)
           
 AbsoluteTime subtract(RelativeTime time)
           
 AbsoluteTime subtract(RelativeTime time, AbsoluteTime dest)
           
 String toString()
           
 
Methods inherited from class lejos.realtime.HighResolutionTime
clone, compareTo, compareTo, equals, equals, getClock, getMilliseconds, getNanoseconds, hashCode, set, set, set, waitForObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbsoluteTime

public AbsoluteTime()
Equivalent to new AbsoluteTime(0,0). The clock association is implicitly made with the real-time clock.


AbsoluteTime

public AbsoluteTime(AbsoluteTime time)
Make a new AbsoluteTime object from the given AbsoluteTime object. The new object will have the same clock association as the time parameter.

Parameters:
time - The AbsoluteTime object which is the source for the copy.
Throws:
IllegalArgumentException - Thrown if the time parameter is null.

AbsoluteTime

public AbsoluteTime(AbsoluteTime time,
                    Clock clock)
Make a new AbsoluteTime object from the given AbsoluteTime object. The clock association is made with the clock parameter. If clock is null the association is made with the real-time clock.

Parameters:
time - The AbsoluteTime object which is the source for the copy.
clock - The clock providing the association for the newly constructed object.
Throws:
IllegalArgumentException - Thrown if the time parameter is null.

AbsoluteTime

public AbsoluteTime(Clock clock)
Equivalent to new AbsoluteTime(0,0,clock). The clock association is made with the clock parameter. If clock is null the association is made with the real-time clock.

Parameters:
clock - The clock providing the association for the newly constructed object.

AbsoluteTime

public AbsoluteTime(Date date)
Equivalent to new AbsoluteTime (date.getTime(),0). The clock association is implicitly made with the real-time clock.

Parameters:
date - The java.util.Date representation of the time past the Epoch.
Throws:
IllegalArgumentException - Thrown if the date parameter is null.

AbsoluteTime

public AbsoluteTime(Date date,
                    Clock clock)
Equivalent to new AbsoluteTime (date.getTime(),0,clock). Warning: While the date is used to set the milliseconds component of the new AbsoluteTime object (with nanoseconds component set to 0), the new object represents the date only if the clock parameter has an epoch equal to Epoch. The clock association is made with the clock parameter. If clock is null the association is made with the real-time clock.

Parameters:
date - The java.util.Date representation of the time past the Epoch.
clock - The clock providing the association for the newly constructed object.
Throws:
IllegalArgumentException - Thrown if the date parameter is null.

AbsoluteTime

public AbsoluteTime(long millis,
                    int nanos)

AbsoluteTime

public AbsoluteTime(long millis,
                    int nanos,
                    Clock clock)
Method Detail

absolute

public AbsoluteTime absolute(Clock clock)
Description copied from class: HighResolutionTime
Convert the time of this to an absolute time, using the given instance of Clock to determine the current time when necessary. If clock is null the real-time clock is assumed. A destination object is allocated to return the result. The clock association of the result is with the clock passed as a parameter. See the derived class comments for more specific information.

Specified by:
absolute in class HighResolutionTime
Parameters:
clock - The instance of Clock used to convert the time of this into absolute time, and the new clock association for the result.
Returns:
The AbsoluteTime conversion in a newly allocated object, associated with the clock parameter.

absolute

public AbsoluteTime absolute(Clock clock,
                             AbsoluteTime dest)
Description copied from class: HighResolutionTime
Convert the time of this to an absolute time, using the given instance of Clock to determine the current time when necessary. If clock is null the real-time clock is assumed. If dest is not null, the result is placed there and returned. Otherwise, a new object is allocated for the result. The clock association of the result is with the clock passed as a parameter. See the derived class comments for more specific information.

Specified by:
absolute in class HighResolutionTime
Parameters:
clock - The instance of Clock used to convert the time of this into absolute time, and the new clock association for the result.
dest - If dest is not null, the result is placed there and returned. Otherwise, a new object is allocated for the result.
Returns:
The AbsoluteTime conversion in dest if dest is not null, otherwise the result is returned in a newly allocated object. It is associated with the clock parameter.

add

public AbsoluteTime add(long millis,
                        int nanos)

add

public AbsoluteTime add(long millis,
                        int nanos,
                        AbsoluteTime dest)

add

public AbsoluteTime add(RelativeTime time)

add

public AbsoluteTime add(RelativeTime time,
                        AbsoluteTime dest)

getDate

public Date getDate()

relative

public RelativeTime relative(Clock clock)
Description copied from class: HighResolutionTime
Convert the time of this to a relative time, using the given instance of Clock to determine the current time when necessary. If clock is null the real-time clock is assumed. A destination object is allocated to return the result. The clock association of the result is with the clock passed as a parameter. See the derived class comments for more specific information.

Specified by:
relative in class HighResolutionTime
Parameters:
clock - The instance of Clock used to convert the time of this into relative time, and the new clock association for the result.
Returns:
The RelativeTime conversion in a newly allocated object, associated with the clock parameter.

relative

public RelativeTime relative(Clock clock,
                             RelativeTime dest)
Description copied from class: HighResolutionTime
Convert the time of this to a relative time, using the given instance of Clock to determine the current time when necessary. If clock is null the real-time clock is assumed. If dest is not null, the result is placed there and returned. Otherwise, a new object is allocated for the result. The clock association of the result is with the clock passed as a parameter. See the derived class comments for more specific information.

Specified by:
relative in class HighResolutionTime
Parameters:
clock - The instance of Clock used to convert the time of this into relative time, and the new clock association for the result.
dest - If dest is not null, the result is placed there and returned. Otherwise, a new object is allocated for the result.
Returns:
The RelativeTime conversion in dest if dest is not null, otherwise the result is returned in a newly allocated object. It is associated with the clock parameter.

set

public void set(Date date)

subtract

public RelativeTime subtract(AbsoluteTime time)

subtract

public RelativeTime subtract(AbsoluteTime time,
                             RelativeTime dest)

subtract

public AbsoluteTime subtract(RelativeTime time)

subtract

public AbsoluteTime subtract(RelativeTime time,
                             AbsoluteTime dest)

toString

public String toString()
Overrides:
toString in class Object