uavsim.datatypes
Class Time

java.lang.Object
  extended by uavsim.datatypes.Time
All Implemented Interfaces:
java.lang.Comparable<Time>, I_Unitable<Time>

public class Time
extends java.lang.Object
implements I_Unitable<Time>

Defines a datatype for time based on seconds.

Author:
Dan Tappan [27.06.11]

Field Summary
private  double _seconds
          the elapsed seconds from time 0
static int MILLISECONDS_PER_SECOND
          the number of milliseconds in a second
static int SECONDS_PER_HOUR
          the number of seconds in an hour
static int SECONDS_PER_MINUTE
          the number of seconds in a minute
 
Constructor Summary
Time()
          Creates a time object with the current real time.
Time(double seconds)
          Creates a time object.
Time(int hour, int minute, double second)
          Creates a time object.
 
Method Summary
 Time add_(Time time)
          Adds another unit to this one.
 int compareTo(Time time)
          
 double getHourComponent()
          Gets the hour component.
 double getMinuteComponent()
          Gets the minute component.
 double getSecondComponent()
          Gets the second component.
 double getSecondHundredths()
          Gets the hundredths component.
 double getSeconds()
          Gets the elapsed seconds that defines the time.
 double getSecondTenths()
          Gets the tenths component.
 double getValue_()
          Returns the numerical value of this unit.
private  void setTime(double seconds)
          Sets the time.
private  void setTime(int hour, int minute, double second)
          Sets the time.
 Time subtract_(Time time)
          Subtract another unit from this one.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_seconds

private double _seconds
the elapsed seconds from time 0


MILLISECONDS_PER_SECOND

public static final int MILLISECONDS_PER_SECOND
the number of milliseconds in a second

See Also:
Constant Field Values

SECONDS_PER_HOUR

public static final int SECONDS_PER_HOUR
the number of seconds in an hour

See Also:
Constant Field Values

SECONDS_PER_MINUTE

public static final int SECONDS_PER_MINUTE
the number of seconds in a minute

See Also:
Constant Field Values
Constructor Detail

Time

public Time()
Creates a time object with the current real time.


Time

public Time(double seconds)
Creates a time object.

Parameters:
seconds - - the elapsed seconds from time 0

Time

public Time(int hour,
            int minute,
            double second)
Creates a time object.

Parameters:
hour - - the hour on the interval [0,23]
minute - - the minute on the interval [0,59]
second - - the second on the interval [0,59]. This may be fractional
Method Detail

add_

public Time add_(Time time)
Adds another unit to this one.

Specified by:
add_ in interface I_Unitable<Time>
Parameters:
time - - the unit
Returns:
the result as a new unit

compareTo

public int compareTo(Time time)

Specified by:
compareTo in interface java.lang.Comparable<Time>

getHourComponent

public double getHourComponent()
Gets the hour component.

Returns:
the component

getMinuteComponent

public double getMinuteComponent()
Gets the minute component.

Returns:
the component

getSecondComponent

public double getSecondComponent()
Gets the second component.

Returns:
the component

getSecondHundredths

public double getSecondHundredths()
Gets the hundredths component.

Returns:
the component

getSeconds

public double getSeconds()
Gets the elapsed seconds that defines the time.

Returns:
the the seconds

getSecondTenths

public double getSecondTenths()
Gets the tenths component.

Returns:
the component

getValue_

public double getValue_()
Returns the numerical value of this unit.

Specified by:
getValue_ in interface I_Unitable<Time>
Returns:
the value

setTime

private void setTime(double seconds)
Sets the time.

Parameters:
seconds - - the elapsed seconds from time 0

setTime

private void setTime(int hour,
                     int minute,
                     double second)
Sets the time.

Parameters:
hour - - the hour on the interval [0,23]
minute - - the minute on the interval [0,59]
second - - the second on the interval [0,59]. This may be fractional

subtract_

public Time subtract_(Time time)
Subtract another unit from this one. A negative result is illegal.

Specified by:
subtract_ in interface I_Unitable<Time>
Parameters:
time - - the unit
Returns:
the result as a new unit

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object