org.oddjob.util
Class DateHelper

java.lang.Object
  extended byorg.oddjob.util.DateHelper

public class DateHelper
extends java.lang.Object

Date Helper Utilities

Author:
Rob Gordon.

Constructor Summary
DateHelper()
           
 
Method Summary
static java.lang.String formatDate(java.util.Date date)
          Format a date into just text representing just the date.
static java.util.Date parseDate(java.lang.String text)
          Parse a date using the default time zone.
static java.util.Date parseDate(java.lang.String text, java.lang.String timeZoneId)
          Parse a date using the given time zone.
static java.util.Date parseDate(java.lang.String text, java.util.TimeZone timeZone)
          Parse a date using the given time zone.
static java.util.Date parseDateTime(java.lang.String text)
          Parse a date and time.
static java.util.Date parseDateTime(java.lang.String text, java.lang.String timeZoneId)
          Parse a date and time in the given time zone.
static java.util.Date parseDateTime(java.lang.String text, java.util.TimeZone timeZone)
          Parse a date and time in the given time zone.
static long parseTime(java.lang.String text)
          Parse a time into a number of milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateHelper

public DateHelper()
Method Detail

parseDateTime

public static java.util.Date parseDateTime(java.lang.String text)
                                    throws java.text.ParseException
Parse a date and time. The input can either be just a date or a date and a time.

Parameters:
text - The date time.
Returns:
The date for the given text in the current time zone.
Throws:
java.text.ParseException - If the text isn't in a recognized date/time foramt.

parseDateTime

public static java.util.Date parseDateTime(java.lang.String text,
                                           java.lang.String timeZoneId)
                                    throws java.text.ParseException
Parse a date and time in the given time zone. The input can either be just a date or a date and time.

Parameters:
text - The date time.
timeZoneId - The time zone identifier.
Returns:
The date for the given text in the specified time zone.
Throws:
java.text.ParseException - If the text isn't in a recognized date/time foramt.

parseDateTime

public static java.util.Date parseDateTime(java.lang.String text,
                                           java.util.TimeZone timeZone)
                                    throws java.text.ParseException
Parse a date and time in the given time zone. The input can either be just a date or a date and time.

Parameters:
text - The date time
timeZone - The timeZone.
Returns:
The date for the given text in the specified time zone.
Throws:
java.text.ParseException - If the text isn't in a recognized date/time foramt.

parseDate

public static java.util.Date parseDate(java.lang.String text)
                                throws java.text.ParseException
Parse a date using the default time zone.

Parameters:
text - A date.
Returns:
The date for the given text.
Throws:
java.text.ParseException - If the date isn't in the recognized date format.

parseDate

public static java.util.Date parseDate(java.lang.String text,
                                       java.lang.String timeZoneId)
                                throws java.text.ParseException
Parse a date using the given time zone.

Parameters:
text - The date text.
timeZoneId - The time zone identifier.
Returns:
The date for the given text in the specified time zone.
Throws:
java.text.ParseException - If the date isn't in the recognized date format.

parseDate

public static java.util.Date parseDate(java.lang.String text,
                                       java.util.TimeZone timeZone)
                                throws java.text.ParseException
Parse a date using the given time zone.

Parameters:
text - The date text.
timeZone - The time zone.
Returns:
The date for the given text in the specified time zone.
Throws:
java.text.ParseException - If the date isn't in the recognized date format.

parseTime

public static long parseTime(java.lang.String text)
                      throws java.text.ParseException
Parse a time into a number of milliseconds.

Parameters:
text - The time.
Returns:
The time as milliseconds.
Throws:
java.text.ParseException - If pasing fails.

formatDate

public static java.lang.String formatDate(java.util.Date date)
Format a date into just text representing just the date.

Parameters:
date - The date
Returns:
The text equivelant.