com.redcarton.alarmclock
Class Time

java.lang.Object
  extended bycom.redcarton.alarmclock.Time
All Implemented Interfaces:
ActionListener, EventListener

public class Time
extends Object
implements ActionListener

Version:
1.0 2005-03-07
Author:
Dominique Bischof

Constructor Summary
Time(TimeListener listener)
          Instantiates a new instance of Time in 24hr format.
Time(TimeListener listener, boolean twentyFourHourFormat)
          Instantiates a new instance of Time.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Do not call directly.
 int getHours()
          Returns the current hour in the appropriate format (24hr or 12hr).
 int getMinutes()
          Returns the current minutes from 0 through 59.
 int getSeconds()
          Returns the current seconds from 0 through 59.
 boolean isAm()
          Returns whether it is currently in the AM.
 boolean isTwentyFourHourFormat()
          Returns whether the time is reported in 24hr format.
 void setTwentyFourHourFormat(boolean twentyFourHourFormat)
          Sets whether to use 24hr format.
 void start()
          Starts the time.
 void stop()
          Stops the time.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Time

public Time(TimeListener listener)
Instantiates a new instance of Time in 24hr format.

Parameters:
listener - The listener to inform when the time changes

Time

public Time(TimeListener listener,
            boolean twentyFourHourFormat)
Instantiates a new instance of Time.

Parameters:
listener - The listener to inform when the time changes
twentyFourHourFormat - true if it is in 24hr format, false if it is in 12hr format
Method Detail

actionPerformed

public void actionPerformed(ActionEvent e)
Do not call directly. Called when the time changes.

Specified by:
actionPerformed in interface ActionListener

getHours

public int getHours()
Returns the current hour in the appropriate format (24hr or 12hr). Returns 0 through 23 in 24hr format, 1 through 12 in 12hr format.

Returns:
the hours

getMinutes

public int getMinutes()
Returns the current minutes from 0 through 59.

Returns:
the minutes

getSeconds

public int getSeconds()
Returns the current seconds from 0 through 59.

Returns:
the seconds

isAm

public boolean isAm()
Returns whether it is currently in the AM.

Returns:
true if it is in the AM, false if it is in the PM

isTwentyFourHourFormat

public boolean isTwentyFourHourFormat()
Returns whether the time is reported in 24hr format.

Returns:
true if it is in 24hr format, false if it is in 12hr format

setTwentyFourHourFormat

public void setTwentyFourHourFormat(boolean twentyFourHourFormat)
Sets whether to use 24hr format.

Parameters:
twentyFourHourFormat - true if it is in 24hr format, false if it is in 12hr format

start

public void start()
Starts the time. The TimeListener will be informed of time changes.


stop

public void stop()
Stops the time. The TimeListener will stop being informed of time changes.