com.ibm.clock
Class Time

java.lang.Object
  extended by com.ibm.clock.Time

public class Time
extends java.lang.Object

Class to represent time of the day. The time of the hour is represented by three fields -- hour, minute and second.


Field Summary
static int HOURS_IN_DAY
          Hours in a day.
static int MINUTES_IN_HOUR
          Minutes in a hour.
static int SECONDS_IN_MINUTE
          Seconds in a minute.
 
Constructor Summary
Time()
          Default constructor.
Time(int hour, int minute, int second)
          Construct a time field given the hour, minute and second fields.
 
Method Summary
 int getHour()
          Get the hour of the day.
 long getInMillis()
          Get the time of the day in milliseconds.
 int getMinute()
          Get the minute field.
 int getSecond()
          Get the second field.
 void setHour(int hour)
          Set the hour field.
 void setMinute(int minute)
          Set the minute field.
 void setSecond(int second)
          Set the second field.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HOURS_IN_DAY

public static final int HOURS_IN_DAY
Hours in a day.

See Also:
Constant Field Values

MINUTES_IN_HOUR

public static final int MINUTES_IN_HOUR
Minutes in a hour.

See Also:
Constant Field Values

SECONDS_IN_MINUTE

public static final int SECONDS_IN_MINUTE
Seconds in a minute.

See Also:
Constant Field Values
Constructor Detail

Time

public Time()
Default constructor. The default time is taken to be zero hour, zero minute, zero second.


Time

public Time(int hour,
            int minute,
            int second)
Construct a time field given the hour, minute and second fields.

Parameters:
hour - The hour of the day. Must be between 0 and 23.
minute - The minute of the hour. Must be between 0 and 59.
second - The second of the minute. Must be between 0 and 59.
Throws:
java.lang.IllegalArgumentException - If any of the arguments is improper.
Method Detail

getInMillis

public long getInMillis()
Get the time of the day in milliseconds. This returns the time in milli seconds from the begining of the day.

Returns:
The time of the day in milliseconds.

getHour

public int getHour()
Get the hour of the day.

Returns:
The hour of the day as an integer lying between 0 and 23.

setHour

public void setHour(int hour)
             throws java.lang.IllegalArgumentException
Set the hour field.

Parameters:
hour - The hour of the day. Must lie between 0 and 23.
Throws:
java.lang.IllegalArgumentException - If the argument is illegal.

getMinute

public int getMinute()
Get the minute field.

Returns:
The minute field as an integer between 0 and 59.

setMinute

public void setMinute(int minute)
Set the minute field.

Parameters:
minute - The minute of the hour. Must lie between 0 and 59.
Throws:
java.lang.IllegalArgumentException - If the argument is illegal.

getSecond

public int getSecond()
Get the second field.

Returns:
The second field as an integer between 0 and 59.

setSecond

public void setSecond(int second)
Set the second field.

Parameters:
second - The second of the hour. Must lie between 0 and 59.
Throws:
java.lang.IllegalArgumentException - If the argument is illegal.