org.treesched
Class DateUtils

java.lang.Object
  extended byorg.treesched.DateUtils

public class DateUtils
extends java.lang.Object

Utility methods to do things with dates and intervals.

Author:
Rob Gordon

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

Method Detail

startOfDay

public static java.util.Date startOfDay(java.util.Date inDate)
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 java.util.Date endOfDay(java.util.Date inDate)
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(java.util.Date inDate)
Calculate the day number for the given date.

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

month

public static int month(java.util.Date inDate)
Calcuate the month number (0 - 11) for the given date.

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

dayOfMonth

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

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

startOfMonth

public static java.util.Date startOfMonth(java.util.Date inDate)
Calculate the date at the start of the month for the given date.

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

endOfMonth

public static java.util.Date endOfMonth(java.util.Date inDate)
Calculate the date at the end of the month for the given date.

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

dayOfYear

public static int dayOfYear(java.util.Date forDate)
Calculate the day of the year for the given date.

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

startOfYear

public static java.util.Date startOfYear(java.util.Date inDate)
Calculate the date at the start of the year for the given date.

Parameters:
inDate - The given date.
Returns:
The date at the start of the year.

endOfYear

public static java.util.Date endOfYear(java.util.Date inDate)
Calcuate the date at the end of the year from the given date.

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

oneMillisAfter

public static java.util.Date oneMillisAfter(java.util.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 java.util.Date oneMillisBefore(java.util.Date date)
Return a date which is 1 millisecond before the given date.

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