driver.ted.utilities
Class T_Time

java.lang.Object
  extended by driver.ted.utilities.T_Time
All Implemented Interfaces:
java.io.Serializable

public class T_Time
extends java.lang.Object
implements java.io.Serializable

Title: T_Time class
Description: Class defining basic time implementation
Copyright: (c) 2002 - 2006
Change History:

Version:
1.1
Author:
Ted Driver
See Also:
Serialized Form

Constructor Summary
T_Time()
          T_Time constructor initializes each instance variable to zero.
T_Time(int h)
          T_Time constructor: hour supplied, minute and second defaulted to 0.
T_Time(int h, int m)
          T_Time constructor: hour and minute supplied, second defaulted to 0.
T_Time(int h, int m, int s)
          T_Time constructor: hour, minute and second supplied.
T_Time(T_Time time)
          T_Time constructor with another T_Time object supplied.
 
Method Summary
 void advanceTime(int h, int m, int s)
          Advances the current time by the specified amounts
 int getHour()
          Provides the current hour
 int getMinute()
          Provides the current minute
 int getSecond()
          Provides the current seconds
 void setHour(int h)
          Sets the hour
 void setMinute(int m)
          Sets the minutes
 void setSecond(int s)
          Sets the seconds
 void setTime(int h, int m, int s)
          Set the time to a new value using 24 hour time.
 java.lang.String toAMPMString()
          Provides the current time in 12 hour (AM/PM) format.
 java.lang.String toString()
          Provides a time output in string format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

T_Time

public T_Time()
T_Time constructor initializes each instance variable to zero. Ensures that T_Time object starts in a consistent state.


T_Time

public T_Time(int h)
T_Time constructor: hour supplied, minute and second defaulted to 0.

Parameters:
h - The integer hour

T_Time

public T_Time(int h,
              int m)
T_Time constructor: hour and minute supplied, second defaulted to 0.

Parameters:
h - The integer hour
m - The integer minute

T_Time

public T_Time(int h,
              int m,
              int s)
T_Time constructor: hour, minute and second supplied.

Parameters:
h - The integer hour
m - The integer minute
s - The integer seconds

T_Time

public T_Time(T_Time time)
T_Time constructor with another T_Time object supplied.

Parameters:
time - The T_Time object to base this one upon.
Method Detail

setTime

public void setTime(int h,
                    int m,
                    int s)
Set the time to a new value using 24 hour time. This function will perform validity checks on the data. If the second or minute values are greater than 59, the minute or hour will be updated as well.

Parameters:
h - The integer hour to set
m - The integer minute to set
s - The integer second to set

advanceTime

public void advanceTime(int h,
                        int m,
                        int s)
Advances the current time by the specified amounts

Parameters:
h - The number of hours to advance (positive or negative)
m - The number of minutes to advance (positive or negative)
s - The number of seconds to advance (positive or negative)

setHour

public void setHour(int h)
Sets the hour

Parameters:
h - The new hour value

setMinute

public void setMinute(int m)
Sets the minutes

Parameters:
m - The new minute value

setSecond

public void setSecond(int s)
Sets the seconds

Parameters:
s - the new seconds value

getHour

public int getHour()
Provides the current hour

Returns:
The integer hour

getMinute

public int getMinute()
Provides the current minute

Returns:
The integer minutes

getSecond

public int getSecond()
Provides the current seconds

Returns:
The integer seconds

toString

public java.lang.String toString()
Provides a time output in string format. Example formats: 02:14:02 and 22:02:17

Overrides:
toString in class java.lang.Object
Returns:
A string representing the current time

toAMPMString

public java.lang.String toAMPMString()
Provides the current time in 12 hour (AM/PM) format. Example time outputs: 02:14:02 AM and 10:02:17 PM

Returns:
A string representing the current time in 12 hour format.