com.deitel.jhtp4.appenF
Class Time3

java.lang.Object
  |
  +--com.deitel.jhtp4.appenF.Time3

public class Time3
extends java.lang.Object

This class maintains the time in 24-hour format.

Author:
Deitel & Associates, Inc.
See Also:
Object

Constructor Summary
Time3()
          Time3 constructor initializes each instance variable to zero.
Time3(int h)
          Time3 constructor: hour supplied, minute and second defaulted to 0
Time3(int h, int m)
          Time3 constructor: hour and minute supplied, second defaulted to 0
Time3(int h, int m, int s)
          Time3 constructor: hour, minute and second supplied
Time3(Time3 time)
          Time3 constructor: another Time3 object supplied
 
Method Summary
 int getHour()
          Gets the hour
 int getMinute()
          Gets the minute
 int getSecond()
          Gets the second
 void setHour(int h)
          Sets the hour
 void setMinute(int m)
          Sets the minute
 void setSecond(int s)
          Sets the second
 void setTime(int h, int m, int s)
          Set a new time value using universal time.
 java.lang.String toString()
          Convert to String in standard-time format
 java.lang.String toUniversalString()
          Convert to String in universal-time format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Time3

public Time3()
      throws java.lang.Exception
Time3 constructor initializes each instance variable to zero. Ensures that Time object starts in a consistent state.
Throws:
Exception - in the case of an invalid time

Time3

public Time3(int h)
      throws java.lang.Exception
Time3 constructor: hour supplied, minute and second defaulted to 0
Parameters:
h - the hour
Throws:
Exception - in the case of an invalid time

Time3

public Time3(int h,
             int m)
      throws java.lang.Exception
Time3 constructor: hour and minute supplied, second defaulted to 0
Parameters:
h - the hour
m - the minute
Throws:
Exception - in the case of an invalid time

Time3

public Time3(int h,
             int m,
             int s)
      throws java.lang.Exception
Time3 constructor: hour, minute and second supplied
Parameters:
h - the hour
m - the minute
s - the second
Throws:
Exception - in the case of an invalid time

Time3

public Time3(Time3 time)
      throws java.lang.Exception
Time3 constructor: another Time3 object supplied
Parameters:
time - Time3 object
Throws:
Exception - in the case of an invalid time
Method Detail

setTime

public void setTime(int h,
                    int m,
                    int s)
             throws java.lang.Exception
Set a new time value using universal time. Perform validity checks on data. Set invalid values to zero.
Parameters:
h - the hour
m - the minute
s - the second
Throws:
Exception - in the case of an invalid time
See Also:
setHour(int), setMinute(int), setSecond(int)

setHour

public void setHour(int h)
             throws java.lang.Exception
Sets the hour
Parameters:
h - the hour
Throws:
java.lang.Exception - in the case of an invalid time

setMinute

public void setMinute(int m)
               throws java.lang.Exception
Sets the minute
Parameters:
m - the minute
Throws:
java.lang.Exception - in the case of an invalid time

setSecond

public void setSecond(int s)
               throws java.lang.Exception
Sets the second
Parameters:
m - the minute
Throws:
java.lang.Exception - in the case of an invalid time

getHour

public int getHour()
Gets the hour
Returns:
an int specifying the hour.

getMinute

public int getMinute()
Gets the minute
Returns:
an int specifying the minute.

getSecond

public int getSecond()
Gets the second
Returns:
an int specifying the second.

toUniversalString

public java.lang.String toUniversalString()
Convert to String in universal-time format
Returns:
a String representation of the time in universal-time format

toString

public java.lang.String toString()
Convert to String in standard-time format
Overrides:
toString in class java.lang.Object
Returns:
a String representation of the time in standard-time format