org.sape.carboncontrib.utils
Class DateTimeUtils

java.lang.Object
  extended byorg.sape.carboncontrib.utils.DateTimeUtils

public class DateTimeUtils
extends Object

Date and Time utilities.


Field Summary
private static int BUF_LEN
          Buffer length for string buffer manipulation
static String DATE_PATTERN
          Date pattern.
static String DATE_TIME_PATTERN
          DateTime pattern.
static String DATE_TIME_TZ_PATTERN
          DateTimeTz pattern.
static String GMT
          GMT TimeZone ID
private static org.apache.commons.logging.Log log
           
 
Constructor Summary
DateTimeUtils()
           
 
Method Summary
static String formatGmtDate(Date date)
          Formats a java.util.Date as a GMT date.
static String formatGmtDateTime(Date date)
          Formats a java.util.Date as a GMT date and time.
static String formatGmtDateTimeTz(Date date)
          Formats a java.util.Date as a GMT date, time and timezone.
static SimpleDateFormat getGmtDateFormat()
          Returns a SimpleDateFormat for GMT time zone and DATE_PATTERN pattern
static SimpleDateFormat getGmtDateTimeFormat()
          Returns a SimpleDateFormat for GMT time zone and DATE_TIME_PATTERN pattern
static SimpleDateFormat getGmtDateTimeTzFormat()
          Returns a SimpleDateFormat for GMT time zone and DATE_TIME_TZ_PATTERN pattern
static SimpleDateFormat getSimpleDateFormat(TimeZone timeZone, String pattern)
          Returns a SimpleDateFormat for the specified time zone and formatting pattern (as specified by SimpleDateFormat).
static Date parseGmtDate(String dateString)
          Parses a GMT date to java.util.Date.
static Date parseGmtDateTime(String dateTimeString)
          Parses a GMT date time to java.util.Date.
static Date parseGmtDateTimeTz(String dateTimeTzString)
          Parses a GMT date, time, timezone to java.util.Date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

BUF_LEN

private static final int BUF_LEN
Buffer length for string buffer manipulation

See Also:
Constant Field Values

DATE_PATTERN

public static final String DATE_PATTERN
Date pattern. Example: 10-28-2002

See Also:
Constant Field Values

DATE_TIME_PATTERN

public static final String DATE_TIME_PATTERN
DateTime pattern. Example: 10-28-2002 02:10:36

See Also:
Constant Field Values

DATE_TIME_TZ_PATTERN

public static final String DATE_TIME_TZ_PATTERN
DateTimeTz pattern. Example: 10-28-2002 02:10:36 GMT

See Also:
Constant Field Values

GMT

public static final String GMT
GMT TimeZone ID

See Also:
Constant Field Values
Constructor Detail

DateTimeUtils

public DateTimeUtils()
Method Detail

getSimpleDateFormat

public static final SimpleDateFormat getSimpleDateFormat(TimeZone timeZone,
                                                         String pattern)
Returns a SimpleDateFormat for the specified time zone and formatting pattern (as specified by SimpleDateFormat).

Parameters:
timeZone - the time zone for the SimpleDateFormat.
pattern - the formatting pattern for the SimpleDateFormat.
Returns:
SimpleDateFormat with specified time zone and pattern

getGmtDateFormat

public static final SimpleDateFormat getGmtDateFormat()
Returns a SimpleDateFormat for GMT time zone and DATE_PATTERN pattern

Returns:
SimpleDateFormat with GMT time zone and DATE_PATTERN pattern

getGmtDateTimeFormat

public static final SimpleDateFormat getGmtDateTimeFormat()
Returns a SimpleDateFormat for GMT time zone and DATE_TIME_PATTERN pattern

Returns:
SimpleDateFormat with GMT time zone and DATE_TIME_PATTERN pattern

getGmtDateTimeTzFormat

public static final SimpleDateFormat getGmtDateTimeTzFormat()
Returns a SimpleDateFormat for GMT time zone and DATE_TIME_TZ_PATTERN pattern

Returns:
SimpleDateFormat with GMT time zone and DATE_TIME_TZ_PATTERN pattern

formatGmtDate

public static final String formatGmtDate(Date date)
Formats a java.util.Date as a GMT date.

Parameters:
date - the date to be formatted
Returns:
String representation of the date.

formatGmtDateTime

public static final String formatGmtDateTime(Date date)
Formats a java.util.Date as a GMT date and time.

Parameters:
date - the date to be formatted
Returns:
String representation of the date.

formatGmtDateTimeTz

public static final String formatGmtDateTimeTz(Date date)
Formats a java.util.Date as a GMT date, time and timezone.

Parameters:
date - the date to be formatted
Returns:
String representation of the date.

parseGmtDate

public static final Date parseGmtDate(String dateString)
                               throws ParseException
Parses a GMT date to java.util.Date.

Parameters:
dateString - the String to be converted to a Date.
Returns:
Date representation of the dateString.
Throws:
ParseException

parseGmtDateTime

public static final Date parseGmtDateTime(String dateTimeString)
                                   throws ParseException
Parses a GMT date time to java.util.Date.

Parameters:
dateTimeString - the String to be converted to a Date.
Returns:
Date representation of the dateTimeString.
Throws:
ParseException

parseGmtDateTimeTz

public static final Date parseGmtDateTimeTz(String dateTimeTzString)
                                     throws ParseException
Parses a GMT date, time, timezone to java.util.Date.

Parameters:
dateTimeTzString - the String to be converted to a Date.
Returns:
Date representation of the dateTimeTzString.
Throws:
ParseException


Copyright 2003 Sapient Corporation. All Rights Reserved.