public final class Dates
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
formatDate(java.util.Date date,
java.lang.String pattern)
Format the given date in the given pattern with system default timezone.
|
static java.lang.String |
formatDateWithTimezone(java.util.Date date,
java.lang.String pattern,
java.lang.String timezone)
Format the given date in the given pattern with the given timezone.
|
static java.util.Map<java.lang.String,java.lang.Integer> |
getMonths()
Returns a mapping of month names by month numbers for the current locale.
|
static java.util.Map<java.lang.String,java.lang.Integer> |
getShortMonths()
Returns a mapping of short month names by month numbers for the current locale.
|
public static java.lang.String formatDate(java.util.Date date, java.lang.String pattern)
title
attribute of an UI component, or the itemLabel
attribute
of select item, or wherever you can't use the <f:convertDateTime>
tag. The format locale will
be set to the one as obtained by Faces.getLocale()
.date
- The date to be formatted in the given pattern.pattern
- The pattern to format the given date in.java.lang.NullPointerException
- When the pattern is null
.formatDateWithTimezone(Date, String, String)
public static java.lang.String formatDateWithTimezone(java.util.Date date, java.lang.String pattern, java.lang.String timezone)
title
attribute of an UI component, or the itemLabel
attribute of
select item, or wherever you can't use the <f:convertDateTime>
tag. The format locale will be
set to the one as obtained by Faces.getLocale()
.date
- The date to be formatted in the given pattern.pattern
- The pattern to format the given date in.timezone
- The timezone to format the given date with.java.lang.NullPointerException
- When the pattern is null
.public static java.util.Map<java.lang.String,java.lang.Integer> getMonths()
<f:selectItems>
which shows all
months. The locale is obtained by Faces.getLocale()
. The mapping is per locale stored in a local cache
to improve retrieving performance.DateFormatSymbols.getMonths()
public static java.util.Map<java.lang.String,java.lang.Integer> getShortMonths()
<f:selectItems>
which shows all
short months. The locale is obtained by Faces.getLocale()
. The mapping is per locale stored in a local
cache to improve retrieving performance.DateFormatSymbols.getShortMonths()