info.magnolia.cms.util
Class DateUtil

java.lang.Object
  extended by info.magnolia.cms.util.DateUtil

public class DateUtil
extends java.lang.Object

Util to format and parse dates.

Version:
$Revision: 41137 $ ($Author: gjoseph $)

Field Summary
static java.lang.String FORMAT_DATE_LONG
           
static java.lang.String FORMAT_DATE_MEDIUM
           
static java.lang.String FORMAT_DATE_SHORT
           
static java.lang.String FORMAT_DATETIME_LONG
           
static java.lang.String FORMAT_DATETIME_MEDIUM
           
static java.lang.String FORMAT_DATETIME_SHORT
           
static java.lang.String FORMAT_DEFAULTPATTERN
          Default date format.
static java.lang.String FORMAT_TIME_LONG
           
static java.lang.String FORMAT_TIME_MEDIUM
           
static java.lang.String FORMAT_TIME_SHORT
           
static java.util.TimeZone UTC_TIME_ZONE
           
static java.lang.String YYYY_MM_DD
           
static java.lang.String YYYY_MM_DD_T_HH_MM_SS
           
 
Method Summary
static java.lang.String format(java.util.Date date, java.lang.String formatPattern)
          Supports implicit formats like: date, date long, datetime, dateime long, time and time long.
static java.lang.String format(java.util.Date date, java.lang.String formatPattern, java.util.Locale locale)
           
static java.lang.String formatDate(java.lang.Object val)
          Uses the current locale (user) to format the date.
static java.lang.String formatDateTime(java.lang.Object val)
          Uses the current locale (user) to format the date and time.
static java.util.Calendar getCurrentUTCCalendar()
          Get UTC Calendar for current time.
static java.util.Calendar getLocalCalendarFromUTC(java.util.Calendar utc)
          Get the equivalent UTC calendar to a local calendar.
static java.util.Calendar getUTCCalendarFromDialogString(java.lang.String dateString)
          Convert a string date from a dialog date to a UTC calendar ready to be stored in the repository.
static java.util.Calendar getUTCCalendarFromLocalDate(java.util.Date date)
          Convert a local date time to a UTC calendar.
static java.util.Date parseDate(java.lang.String dateStr)
          Uses the current locale (user) to parse the date.
static java.util.Date parseDateTime(java.lang.String dateStr)
          Uses the current locale (user) to parse the date and time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMAT_DATE_SHORT

public static final java.lang.String FORMAT_DATE_SHORT
See Also:
Constant Field Values

FORMAT_DATE_MEDIUM

public static final java.lang.String FORMAT_DATE_MEDIUM
See Also:
Constant Field Values

FORMAT_DATE_LONG

public static final java.lang.String FORMAT_DATE_LONG
See Also:
Constant Field Values

FORMAT_DATETIME_SHORT

public static final java.lang.String FORMAT_DATETIME_SHORT
See Also:
Constant Field Values

FORMAT_DATETIME_MEDIUM

public static final java.lang.String FORMAT_DATETIME_MEDIUM
See Also:
Constant Field Values

FORMAT_DATETIME_LONG

public static final java.lang.String FORMAT_DATETIME_LONG
See Also:
Constant Field Values

FORMAT_TIME_SHORT

public static final java.lang.String FORMAT_TIME_SHORT
See Also:
Constant Field Values

FORMAT_TIME_MEDIUM

public static final java.lang.String FORMAT_TIME_MEDIUM
See Also:
Constant Field Values

FORMAT_TIME_LONG

public static final java.lang.String FORMAT_TIME_LONG
See Also:
Constant Field Values

FORMAT_DEFAULTPATTERN

public static final java.lang.String FORMAT_DEFAULTPATTERN
Default date format.

See Also:
Constant Field Values

YYYY_MM_DD

public static final java.lang.String YYYY_MM_DD
See Also:
Constant Field Values

YYYY_MM_DD_T_HH_MM_SS

public static final java.lang.String YYYY_MM_DD_T_HH_MM_SS
See Also:
Constant Field Values

UTC_TIME_ZONE

public static final java.util.TimeZone UTC_TIME_ZONE
Method Detail

format

public static java.lang.String format(java.util.Date date,
                                      java.lang.String formatPattern)
Supports implicit formats like: date, date long, datetime, dateime long, time and time long.


format

public static java.lang.String format(java.util.Date date,
                                      java.lang.String formatPattern,
                                      java.util.Locale locale)

formatDateTime

public static java.lang.String formatDateTime(java.lang.Object val)
Uses the current locale (user) to format the date and time.

Parameters:
val - Date or Calendar
Returns:
the String

formatDate

public static java.lang.String formatDate(java.lang.Object val)
Uses the current locale (user) to format the date.

Parameters:
val - Date or Calendar
Returns:
the String

parseDateTime

public static java.util.Date parseDateTime(java.lang.String dateStr)
                                    throws java.text.ParseException
Uses the current locale (user) to parse the date and time.

Parameters:
val - Date or Calendar
Returns:
the String
Throws:
java.text.ParseException

parseDate

public static java.util.Date parseDate(java.lang.String dateStr)
                                throws java.text.ParseException
Uses the current locale (user) to parse the date.

Parameters:
val - Date or Calendar
Returns:
the String
Throws:
java.text.ParseException

getLocalCalendarFromUTC

public static java.util.Calendar getLocalCalendarFromUTC(java.util.Calendar utc)
Get the equivalent UTC calendar to a local calendar.


getUTCCalendarFromDialogString

public static java.util.Calendar getUTCCalendarFromDialogString(java.lang.String dateString)
                                                         throws java.text.ParseException
Convert a string date from a dialog date to a UTC calendar ready to be stored in the repository.

Throws:
java.text.ParseException

getUTCCalendarFromLocalDate

public static java.util.Calendar getUTCCalendarFromLocalDate(java.util.Date date)
Convert a local date time to a UTC calendar.


getCurrentUTCCalendar

public static java.util.Calendar getCurrentUTCCalendar()
Get UTC Calendar for current time.



Copyright © 2003-2011 Magnolia International Ltd.. All Rights Reserved.