Package org.opencms.util
Class CmsDateUtil
java.lang.Object
org.opencms.util.CmsDateUtil
Utilities to get and set formated dates in OpenCms.
- Since:
- 6.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final TimeZoneThe "GMT" time zone, used when formatting http headers.protected static final DateFormatThe default format to use when formatting http headers.protected static final DateFormatThe default format to use when formatting old cookies. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns a formated date String from a Date value, the formatting based on the provided options.static StringgetDateShort(long time) Returns a formated date String form a timestamp value, the formatting based on the OpenCms system default locale and theDateFormat.SHORTdate format.static StringgetDateTime(Date date, int format, Locale locale) Returns a formated date and time String from a Date value, the formatting based on the provided options.static StringgetDateTimeShort(long time) Returns a formated date and time String form a timestamp value, the formatting based on the OpenCms system default locale and theDateFormat.SHORTdate format.static intgetDaysPassedSince(Date dateLastModified) Returns the number of days passed since a specific date.static StringgetHeaderDate(long time) Returns a formated date and time String form a timestamp value based on the HTTP-Header date format.static StringgetOldCookieDate(long time) Returns a formatted date and time String form a timestamp value based on the (old) Netscape cookie date format.static longparseDate(int year, int month, int date) Returns the long value of a date created by the given integer values.static longparseHeaderDate(String timestamp) Parses a formated date and time string in HTTP-Header date format and returns the time value.
-
Field Details
-
GMT_TIMEZONE
The "GMT" time zone, used when formatting http headers. -
HEADER_DEFAULT
The default format to use when formatting http headers. -
OLD_COOKIE
The default format to use when formatting old cookies.
-
-
Method Details
-
getDate
Returns a formated date String from a Date value, the formatting based on the provided options.- Parameters:
date- the Date object to format as Stringformat- the format to use, seeDateFormatfor possible valueslocale- the locale to use- Returns:
- the formatted date
-
getDateShort
Returns a formated date String form a timestamp value, the formatting based on the OpenCms system default locale and theDateFormat.SHORTdate format.- Parameters:
time- the time value to format as date- Returns:
- the formatted date
-
getDateTime
Returns a formated date and time String from a Date value, the formatting based on the provided options.- Parameters:
date- the Date object to format as Stringformat- the format to use, seeDateFormatfor possible valueslocale- the locale to use- Returns:
- the formatted date
-
getDateTimeShort
Returns a formated date and time String form a timestamp value, the formatting based on the OpenCms system default locale and theDateFormat.SHORTdate format.- Parameters:
time- the time value to format as date- Returns:
- the formatted date
-
getDaysPassedSince
Returns the number of days passed since a specific date.- Parameters:
dateLastModified- the date to compute the passed days from- Returns:
- the number of days passed since a specific date
-
getHeaderDate
Returns a formated date and time String form a timestamp value based on the HTTP-Header date format.- Parameters:
time- the time value to format as date- Returns:
- the formatted date
-
getOldCookieDate
Returns a formatted date and time String form a timestamp value based on the (old) Netscape cookie date format.- Parameters:
time- the time value to format as date- Returns:
- the formatted date
-
parseDate
Returns the long value of a date created by the given integer values.- Parameters:
year- the integer value of yearmonth- the integer value of monthdate- the integer value of date- Returns:
- the long value of a date created by the given integer values
-
parseHeaderDate
Parses a formated date and time string in HTTP-Header date format and returns the time value.- Parameters:
timestamp- the timestamp in HTTP-Header date format- Returns:
- time value as long
- Throws:
ParseException- if parsing fails
-