ccs.utils
Class TimeOfDay

java.lang.Object
  extended by ccs.utils.TimeOfDay

public class TimeOfDay
extends java.lang.Object

Utility methods for events which occur at a fixed time of day.


Method Summary
static int minutesSinceMidnight(long timeMillis, java.util.Calendar cal)
          Convert a time into the number of minutes since midnight.
static int minutesSinceMidnight(java.lang.String time)
          Convert a time into the number of minutes since midnight.
static java.lang.String toString(int minutesSinceMidnight)
          Convert a time offset since midnight into our string format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

minutesSinceMidnight

public static int minutesSinceMidnight(java.lang.String time)
                                throws java.lang.NumberFormatException
Convert a time into the number of minutes since midnight.

Parameters:
time - The time to convert. The format is four digits HHmm, in 24-hour clock, with no punctuation between the two components. Midnight is 0000, not 2400.
Returns:
The number of minutes since midnight that this time represents.
Throws:
java.lang.NumberFormatException - if time does not conform to the required format.

minutesSinceMidnight

public static int minutesSinceMidnight(long timeMillis,
                                       java.util.Calendar cal)
Convert a time into the number of minutes since midnight.

Parameters:
timeMillis - The time to convert, in millseconds since the epoch.
cal - The calendar to go by. Calendar.getInstance will do in many cases. NB. The time of this calendar will be set.
Returns:
The number of minutes since the most recently-passed midnight on the specified calendar.

toString

public static java.lang.String toString(int minutesSinceMidnight)
Convert a time offset since midnight into our string format. The inverse of minutesSinceMidnight.