public final class CmsDateUtil
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.TimeZone |
GMT_TIMEZONE
The "GMT" time zone, used when formatting http headers.
|
protected static java.text.DateFormat |
HEADER_DEFAULT
The default format to use when formatting http headers.
|
protected static java.text.DateFormat |
OLD_COOKIE
The default format to use when formatting old cookies.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getDate(java.util.Date date,
int format,
java.util.Locale locale)
Returns a formated date String from a Date value,
the formatting based on the provided options.
|
static java.lang.String |
getDateTime(java.util.Date date,
int format,
java.util.Locale locale)
Returns a formated date and time String from a Date value,
the formatting based on the provided options.
|
static int |
getDaysPassedSince(java.util.Date dateLastModified)
Returns the number of days passed since a specific date.
|
static java.lang.String |
getHeaderDate(long time)
Returns a formated date and time String form a timestamp value based on the
HTTP-Header date format.
|
static java.lang.String |
getOldCookieDate(long time)
Returns a formated date and time String form a timestamp value based on the
(old) Netscape cookie date format.
|
static long |
parseHeaderDate(java.lang.String timestamp)
Parses a formated date and time string in HTTP-Header date format and returns the
time value.
|
protected static final java.util.TimeZone GMT_TIMEZONE
protected static final java.text.DateFormat HEADER_DEFAULT
protected static final java.text.DateFormat OLD_COOKIE
public static java.lang.String getDate(java.util.Date date,
int format,
java.util.Locale locale)
date - the Date object to format as Stringformat - the format to use, see DateFormat for possible valueslocale - the locale to usepublic static java.lang.String getDateTime(java.util.Date date,
int format,
java.util.Locale locale)
date - the Date object to format as Stringformat - the format to use, see DateFormat for possible valueslocale - the locale to usepublic static int getDaysPassedSince(java.util.Date dateLastModified)
dateLastModified - the date to compute the passed days frompublic static java.lang.String getHeaderDate(long time)
time - the time value to format as datepublic static java.lang.String getOldCookieDate(long time)
time - the time value to format as datepublic static long parseHeaderDate(java.lang.String timestamp)
throws java.text.ParseException
timestamp - the timestamp in HTTP-Header date formatjava.text.ParseException - if parsing fails