public final class Dates extends Object
Modifier and Type | Method and Description |
---|---|
static String |
formatDate(Date date,
String pattern)
Format the given date in the given pattern with system default timezone.
|
static String |
formatDateWithTimezone(Date date,
String pattern,
String timezone)
Format the given date in the given pattern with the given timezone.
|
static Map<String,Integer> |
getMonths()
Returns a mapping of month names by month numbers for the current locale.
|
static Map<String,Integer> |
getShortMonths()
Returns a mapping of short month names by month numbers for the current locale.
|
public static String formatDate(Date date, 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.NullPointerException
- When the pattern is null
.formatDateWithTimezone(Date, String, String)
public static String formatDateWithTimezone(Date date, String pattern, 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.NullPointerException
- When the pattern is null
.public static Map<String,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 Map<String,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()