|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ScheduledTime
public class ScheduledTime
The ScheduledTime class is a simplified encapsulation of times. A ScheduledTime object has hours and minutes. Hours in the set {8,9,10,11} are considered AM and hours in the interval {12,1,2,3,4,5,6,7} are considered PM. Minutes must be the interval [0,59].
When operating on ScheduledTime objects, the minutes will be truncated. The 'truncation value' can be changed using the setTruncationValue() method. By default, the truncation value is set to 1, which has no impact on operations. When set to 5, for example, 8:01 will be truncated to 8:00 and 8:49 will be truncated to 8:45.
A ScheduledTime object is immutable. That is, once it is created, its attributes can't be changed. (However, the way in which ScheduledTime objects are operated on can be changed using the setTruncationValue() method.)
Constructor Summary | |
---|---|
ScheduledTime(int hour,
int minute)
Explicit Value Constructor |
|
ScheduledTime(java.lang.String hhmm)
Explicit Value Constructor |
Method Summary | |
---|---|
int |
compareTo(ScheduledTime other)
Compare this ScheduledTime to the ScheduledTime named other. |
int |
getHour()
Get the hour associated with this ScheduledTime |
int |
getMinute()
Get the minute (truncated appropriately) associated with this ScheduledTime |
static void |
setTruncationValue(int value)
Set the truncation value to use for all ScheduledTime objects. |
java.lang.String |
toString()
Returns a String representation of this ScheduledTime formatted as hh:mm (with the minute truncated appropriately) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ScheduledTime(int hour, int minute) throws java.lang.IllegalArgumentException
Explicit Value Constructor
If the hour or minute is invalid, this constructor throws an IllegalArgumentException.
hour
- The hour for this ScheduledTimeminute
- The minute for this ScheduledTime
java.lang.IllegalArgumentException
public ScheduledTime(java.lang.String hhmm) throws java.lang.IllegalArgumentException
Explicit Value Constructor
If the String representation is invalid, this constructor throws an IllegalArgumentException.
hhmm
- A String representation (in hh:mm format)
java.lang.IllegalArgumentException
Method Detail |
---|
public int compareTo(ScheduledTime other)
Compare this ScheduledTime to the ScheduledTime named other. This method returns -1 if this is earlier than other, 0 if this is the same is other, and 1 if this is after other.
Note that this method truncates the minutes when performing the comparison. So, if the truncation value is 5, 8:00 and 8:04 are the same.
public int getHour()
public int getMinute()
public static void setTruncationValue(int value)
value
- The truncation value to usepublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |