org.oddjob.schedules
Class DateUtils

java.lang.Object
  extended by org.oddjob.schedules.DateUtils

public class DateUtils
extends Object

Utility methods to do things with dates and intervals.

Author:
Rob Gordon

Method Summary
static int compare(Calendar c1, Calendar c2)
          Compare to calendars.
static int dayOfMonth(Date inDate, TimeZone timeZone)
          Calculate the day of the month (1 - 31) for the given date.
static int dayOfWeek(Date inDate, TimeZone timeZone)
          Calculate the day number for the given date.
static int dayOfYear(Date forDate, TimeZone timeZone)
          Calculate the day of the year for the given date.
static Date endOfDay(Date inDate, TimeZone timeZone)
          Calculate the date time at the end of the day (one millisecond before midnight) for the given date.
static int month(Date inDate, TimeZone timeZone)
          Calcuate the month number (0 - 11) for the given date.
static Date oneMillisAfter(Date date)
          Return a date which is 1 millisecond after the given date.
static Date oneMillisBefore(Date date)
          Return a date which is 1 millisecond before the given date.
static Date startOfDay(Date inDate, TimeZone timeZone)
          Calculate the start of day date time (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

startOfDay

public static Date startOfDay(Date inDate,
                              TimeZone timeZone)
Calculate the start of day date time (i.e. at 00:00) for a given date.

Parameters:
inDate - The date to cacluate start of day from.
Returns:
The Date at the start of the day.

endOfDay

public static Date endOfDay(Date inDate,
                            TimeZone timeZone)
Calculate the date time at the end of the day (one millisecond before midnight) for the given date.

Parameters:
inDate - The given date.
Returns:
The Date at the end of the day.

dayOfWeek

public static int dayOfWeek(Date inDate,
                            TimeZone timeZone)
Calculate the day number for the given date.

Parameters:
inDate - The given date.
Returns:
The day number.

month

public static int month(Date inDate,
                        TimeZone timeZone)
Calcuate the month number (0 - 11) for the given date.

Parameters:
inDate - The given date.
Returns:
The month number.

dayOfMonth

public static int dayOfMonth(Date inDate,
                             TimeZone timeZone)
Calculate the day of the month (1 - 31) for the given date.

Parameters:
inDate - The given date.
Returns:
The day of the month.

dayOfYear

public static int dayOfYear(Date forDate,
                            TimeZone timeZone)
Calculate the day of the year for the given date.

Parameters:
forDate - The date.
Returns:
The day of the year.

oneMillisAfter

public static Date oneMillisAfter(Date date)
Return a date which is 1 millisecond after the given date.

Parameters:
date - The given date.
Returns:
The date one millisecond later.

oneMillisBefore

public static Date oneMillisBefore(Date date)
Return a date which is 1 millisecond before the given date.

Parameters:
date - The given date.
Returns:
The date one millisecond before.

compare

public static int compare(Calendar c1,
                          Calendar c2)
Compare to calendars.

Parameters:
c1 - First calendar.
c2 - Second calendar
Returns:
1 if c1 > c2, 0 if c1 = c2, -1 if c1 < c2.