org.oddjob.arooa.utils
Class DateHelper

java.lang.Object
  extended by org.oddjob.arooa.utils.DateHelper

public class DateHelper
extends Object

Date Helper Utilities

Author:
Rob Gordon.

Constructor Summary
DateHelper()
           
 
Method Summary
static String formatDate(Date date)
          Format a date into just text representing just the date.
static String formatDate(Date date, TimeZone timeZone)
          Format a date into just text representing just the date.
static String formatDateTime(Date date)
          Format a date into full date/time text.
static String formatDateTime(Date date, TimeZone timeZone)
          Format a date into full date/time text.
static String formatDateTimeInteligently(Date date)
          Format date time with or without milliseconds.
static String formatDateTimeInteligently(Date date, TimeZone timeZone)
          Format date time with or without milliseconds.
static String formatMilliseconds(long milliseconds)
           
static Date parseDate(String text)
          Parse a date using the default time zone.
static Date parseDate(String text, String timeZoneId)
          Parse a date using the given time zone.
static Date parseDate(String text, TimeZone timeZone)
          Parse a date using the given time zone.
static Date parseDateTime(String text)
          Parse a date and time.
static Date parseDateTime(String text, String timeZoneId)
          Parse a date and time in the given time zone.
static Date parseDateTime(String text, TimeZone timeZone)
          Parse a date and time in the given time zone.
static long parseTime(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 Date parseDateTime(String text)
                          throws 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:
ParseException - If the text isn't in a recognised date/time format.

parseDateTime

public static Date parseDateTime(String text,
                                 String timeZoneId)
                          throws 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:
ParseException - If the text isn't in a recognised date/time format.

parseDateTime

public static Date parseDateTime(String text,
                                 TimeZone timeZone)
                          throws 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:
ParseException - If the text isn't in a recognised date/time format.

parseDate

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

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

parseDate

public static Date parseDate(String text,
                             String timeZoneId)
                      throws 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:
ParseException - If the date isn't in the recognised date format.

parseDate

public static Date parseDate(String text,
                             TimeZone timeZone)
                      throws 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:
ParseException - If the date isn't in the recognised date format.

parseTime

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

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

formatDate

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

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

formatDate

public static String formatDate(Date date,
                                TimeZone timeZone)
Format a date into just text representing just the date.

Parameters:
date - The date
timeZone - The time zone.
Returns:
The text equivalent.

formatDateTime

public static String formatDateTime(Date date)
Format a date into full date/time text.

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

formatDateTime

public static String formatDateTime(Date date,
                                    TimeZone timeZone)
Format a date into full date/time text.

Parameters:
date - The date
timeZone - The time zone.
Returns:
The text equivalent.

formatDateTimeInteligently

public static String formatDateTimeInteligently(Date date)
Format date time with or without milliseconds.

Parameters:
date -
Returns:

formatDateTimeInteligently

public static String formatDateTimeInteligently(Date date,
                                                TimeZone timeZone)
Format date time with or without milliseconds.

Parameters:
date -
timeZone -
Returns:

formatMilliseconds

public static String formatMilliseconds(long milliseconds)