javax.realtime
Class AbsoluteTime

java.lang.Object
  |
  +--javax.realtime.HighResolutionTime
        |
        +--javax.realtime.AbsoluteTime

public class AbsoluteTime
extends HighResolutionTime

An object that represents a specific point in time given by milliseconds plus nanoseconds past the epoch (January 1, 1970, 00:00:00 GMT). This representation was designed to be compatible with the standard Java representation of an absolute time in the Date class.

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.


Constructor Summary
AbsoluteTime()
          Equal to new AbsoluteTime(0,0).
AbsoluteTime(AbsoluteTime time)
          make a new AbsolutTime object from the given AbsoluteTime object
AbsoluteTime(java.util.Date date)
          Equivalent to new AbsoluteTime (date.getTime(),0)
AbsoluteTime(long millis, int nanos)
          Construct an AbsoluteTime object which means a time millis milliseconds plus nanos nanoseconds past00:00:00 GMT on January 1, 1970.
 
Method Summary
 AbsoluteTime absolute(Clock clock)
          Convert this time to an absolute time relative to a given clock.
 AbsoluteTime absolute(Clock clock, AbsoluteTime destination)
          Convert this time to an absolute time.
 AbsoluteTime add(long millis, int nanos)
          add millis and nanos to this.
 AbsoluteTime add(long millis, int nanos, AbsoluteTime destination)
          If a destination is non-null, the result is placed there and the destination is returned.
 AbsoluteTime add(RelativeTime time)
          Return this + time.
 AbsoluteTime add(RelativeTime time, AbsoluteTime destination)
          The purpose of "destination" is unclear, for the result is returned anyway.
 java.util.Date getDate()
           
 RelativeTime relative(Clock clock)
           
 RelativeTime relative(Clock clock, RelativeTime destination)
           
 void set(java.util.Date date)
          Change the time represented by this.
 RelativeTime subtract(AbsoluteTime time)
           
 RelativeTime subtract(AbsoluteTime time, RelativeTime destination)
           
 AbsoluteTime subtract(RelativeTime time)
           
 AbsoluteTime subtract(RelativeTime time, AbsoluteTime destination)
           
 java.lang.String toString()
          Return a printable version of this time, in a format that matches java.util.Date.toString() with a postfix to the detail the sub-second value
 
Methods inherited from class javax.realtime.HighResolutionTime
compareTo, compareTo, equals, equals, getMilliseconds, getNanoseconds, hashCode, set, set, set, waitForObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbsoluteTime

public AbsoluteTime()
Equal to new AbsoluteTime(0,0).

AbsoluteTime

public AbsoluteTime(AbsoluteTime time)
make a new AbsolutTime object from the given AbsoluteTime object
Parameters:
time - The AbsolutTime object as the source for the copy

AbsoluteTime

public AbsoluteTime(java.util.Date date)
Equivalent to new AbsoluteTime (date.getTime(),0)
Parameters:
date - The java.util.Data representation of the time past the epoch

AbsoluteTime

public AbsoluteTime(long millis,
                    int nanos)
Construct an AbsoluteTime object which means a time millis milliseconds plus nanos nanoseconds past00:00:00 GMT on January 1, 1970.
Parameters:
millis - The milliseconds component of the time past the epoch
nanos - The nanosecond component of the time past the epoch
Method Detail

absolute

public AbsoluteTime absolute(Clock clock,
                             AbsoluteTime destination)
Convert this time to an absolute time. For an AbsoluteTime, this is really easy: it just return itself. Presumes that this time is already relative to the given clock.
Overrides:
absolute in class HighResolutionTime
Parameters:
clock - Clock on which this is based
destination - Converted to an absolute time
Returns:
this

absolute

public AbsoluteTime absolute(Clock clock)
Convert this time to an absolute time relative to a given clock.
Overrides:
absolute in class HighResolutionTime
Parameters:
clock - Clock on which this is based
Returns:
this

relative

public RelativeTime relative(Clock clock)
Overrides:
relative in class HighResolutionTime

relative

public RelativeTime relative(Clock clock,
                             RelativeTime destination)
Overrides:
relative in class HighResolutionTime

add

public AbsoluteTime add(long millis,
                        int nanos)
add millis and nanos to this. A new object is allocated for the result
Parameters:
millis - the milliseconds value to be added to this
nanos - the nanoseconds value to be added to this
Returns:
the result after adding this with millis and nanos.

add

public AbsoluteTime add(long millis,
                        int nanos,
                        AbsoluteTime destination)
If a destination is non-null, the result is placed there and the destination is returned. Otherwise a new object is allocated for the result.
Parameters:
millis - milliseconds
nanos - nanoseconds
Returns:
the result

add

public final AbsoluteTime add(RelativeTime time)
Return this + time. A new object is allocated for the result.
Parameters:
time - the time to add to this
Returns:
the result

add

public AbsoluteTime add(RelativeTime time,
                        AbsoluteTime destination)
The purpose of "destination" is unclear, for the result is returned anyway. Return this + time. If destination is non-null, the result is placed there and destination is returned. Otherwise a new object is allocated for the result.
Parameters:
time - the time to add to this
destination - to place the result in
Returns:
the result

getDate

public java.util.Date getDate()
Returns:
The time past the epoch represented by this as a java.util.Date.

set

public void set(java.util.Date date)
Change the time represented by this.
Parameters:
date - java.util.Date which becomes the time represented by this after the completion of this method.

subtract

public final RelativeTime subtract(AbsoluteTime time)
Parameters:
time - absolute time to subtract from this
Returns:
this-time. A new object is allocated for the result.

subtract

public final RelativeTime subtract(AbsoluteTime time,
                                   RelativeTime destination)
Parameters:
time - absolute time to subtract from this
destination - place to store the result. New object allocated if null
Returns:
this-time. A new object is allocated for the result.

subtract

public final AbsoluteTime subtract(RelativeTime time)
Parameters:
time - relative time to subtract from this
Returns:
this-time. A new object is allocated for the result.

subtract

public AbsoluteTime subtract(RelativeTime time,
                             AbsoluteTime destination)
Parameters:
time - relative time to subtract from this
destination - place to store the result. New object allocated if null
Returns:
this-time. A new object is allocated for the result.

toString

public java.lang.String toString()
Return a printable version of this time, in a format that matches java.util.Date.toString() with a postfix to the detail the sub-second value
Overrides:
toString in class java.lang.Object
Returns:
String object converted from this.