info.magnolia.cms.util
Class DateUtil

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

public class DateUtil
extends Object

Util to format and parse dates.

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

Field Summary
static String FORMAT_DATE_LONG
           
static String FORMAT_DATE_MEDIUM
           
static String FORMAT_DATE_SHORT
           
static String FORMAT_DATETIME_LONG
           
static String FORMAT_DATETIME_MEDIUM
           
static String FORMAT_DATETIME_SHORT
           
static String FORMAT_DEFAULTPATTERN
          Default date format.
static String FORMAT_TIME_LONG
           
static String FORMAT_TIME_MEDIUM
           
static String FORMAT_TIME_SHORT
           
static TimeZone UTC_TIME_ZONE
           
static String YYYY_MM_DD
           
static String YYYY_MM_DD_T_HH_MM_SS
           
 
Method Summary
static String format(Date date, String formatPattern)
          Supports implicit formats like: date, date long, datetime, dateime long, time and time long.
static String format(Date date, String formatPattern, Locale locale)
           
static String formatDate(Object val)
          Uses the current locale (user) to format the date.
static String formatDateTime(Object val)
          Uses the current locale (user) to format the date and time.
static Calendar getCurrentUTCCalendar()
          Get UTC Calendar for current time.
static Calendar getLocalCalendarFromUTC(Calendar utc)
          Get the equivalent UTC calendar to a local calendar.
static Calendar getUTCCalendarFromDialogString(String dateString)
          Convert a string date from a dialog date to a UTC calendar ready to be stored in the repository.
static Calendar getUTCCalendarFromLocalDate(Date date)
          Convert a local date time to a UTC calendar.
static Date parseDate(String dateStr)
          Uses the current locale (user) to parse the date.
static Date parseDateTime(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 String FORMAT_DATE_SHORT
See Also:
Constant Field Values

FORMAT_DATE_MEDIUM

public static final String FORMAT_DATE_MEDIUM
See Also:
Constant Field Values

FORMAT_DATE_LONG

public static final String FORMAT_DATE_LONG
See Also:
Constant Field Values

FORMAT_DATETIME_SHORT

public static final String FORMAT_DATETIME_SHORT
See Also:
Constant Field Values

FORMAT_DATETIME_MEDIUM

public static final String FORMAT_DATETIME_MEDIUM
See Also:
Constant Field Values

FORMAT_DATETIME_LONG

public static final String FORMAT_DATETIME_LONG
See Also:
Constant Field Values

FORMAT_TIME_SHORT

public static final String FORMAT_TIME_SHORT
See Also:
Constant Field Values

FORMAT_TIME_MEDIUM

public static final String FORMAT_TIME_MEDIUM
See Also:
Constant Field Values

FORMAT_TIME_LONG

public static final String FORMAT_TIME_LONG
See Also:
Constant Field Values

FORMAT_DEFAULTPATTERN

public static final String FORMAT_DEFAULTPATTERN
Default date format.

See Also:
Constant Field Values

YYYY_MM_DD

public static final String YYYY_MM_DD
See Also:
Constant Field Values

YYYY_MM_DD_T_HH_MM_SS

public static final String YYYY_MM_DD_T_HH_MM_SS
See Also:
Constant Field Values

UTC_TIME_ZONE

public static final TimeZone UTC_TIME_ZONE
Method Detail

format

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


format

public static String format(Date date,
                            String formatPattern,
                            Locale locale)

formatDateTime

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

Parameters:
val - Date or Calendar
Returns:
the String

formatDate

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

Parameters:
val - Date or Calendar
Returns:
the String

parseDateTime

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

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

parseDate

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

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

getLocalCalendarFromUTC

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


getUTCCalendarFromDialogString

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

Throws:
ParseException

getUTCCalendarFromLocalDate

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


getCurrentUTCCalendar

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



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