| |
|
|
|
 |
Home NewsBlogProducts Download Buy Now Documentation Support |
 |
 |
|
|
 |
| |


Contents
|
12. JSF Tag Reference
Contents > JSF Tag Reference > JSF Core Tags
10. JSF Core Tag Reference
Contents > JSF Core Tag Reference > f:convertDateTime
f:convertDateTime |
|
The ConvertDateTime tag is useful for converting a date into a human-readable format and supports a range of formatting options. You can use this tag to control the style and appearance of a date on your JSF page. The ConvertDateTime tag applies to the date value of the component associated with the enclosing tag. The body content of this tag must be empty.
Example:
<h:outputText value="#{dateBean.today}">
<f:convertDateTime dateStyle="full" timeZone="EST" type="date" />
</h:outputText>
HTML Output
Sunday, January 1, 2006
|
Tag Attributes
| dateStyle |
String |
| |
This attribute sets a predefined formatting style which determines how a date string is to be formatted. It only applies the type attribute is "date" or "both". Valid values for this attribute are:
| Date Style |
Example |
| default |
Jan 1, 2006 1:20:45 PM |
| short |
1/1/06 1:20:45 PM |
| medium |
Jan 1, 2006 1:20:45 PM |
| long |
January 1, 2006 1:20:45 PM |
| full |
Sunday, January 1, 2006 1:20:45 PM |
The default value is "default". |
| locale |
String |
| |
The locale attribute sets the locale whose predefined styles for dates and times are used during formatting. If not specified, the Locale returned by FacesContext.getViewRoot().getLocale() will be used.
The locale value must be either a value-binding expression that evaluates to a java.util.Locale instance, or a String that is acceptable as the first argument to the constructor java.util.Locale(String language, String country). An empty string is passed as the second argument.
JSFToolbox automatically detects which locales your application supports when it scans the Faces configuration files for your site. You can simply choose the locale for which you want to format this date from the inspector panel for your tag. |
| pattern |
String |
| |
The pattern attribute sets the custom formatting pattern which determines how the date/time string should be formatted and parsed.
| Pattern |
Result |
| yyyy.MM.dd 'at' HH:mm:ss z |
2006.01.01 at 10:05:30 EST |
| EEE, MMM d, ''yy |
Sun, Jan 1, '06 |
| h:mm a |
10:05 AM |
| hh 'o''clock' a, zzzz |
10 o'clock AM, Eastern Standard Time |
| EEE, d MMM yyyy HH:mm:ss Z |
Sun, 1 Jan 2006 10:05:30 -0500 |
For more examples of date formatting patterns, please see the Java API documentation for java.text.SimpleDateFormat. |
| timeStyle |
String |
| |
The timeStyle attribute sets a predefined formatting style which determines how a time string is to be formatted and parsed. Applied only if the type attribute is "time" or "both". Valid values are:
| Date Style |
Example |
| default |
Jan 1, 2006 10:05:30 AM |
| short |
1/1/06 10:05:30 AM |
| medium |
Jan 1, 2006 10:05:30 AM |
| long |
January 1, 2006 10:05:30 AM |
| full |
Sunday, January 1, 2006 10:05:30 AM |
The default value is "default". |
| timeZone |
String |
| |
| This attribute sets the time zone for which to interpret date/time information. The value must be either a value-binding expression that evaluates to a java.util.TimeZone instance, or a String that is a timezone ID as per the Java API documentation for java.util.TimeZone.getTimeZone(). |
| type |
String |
| |
| This attributes specifies what type of information the string to be formatted or parsed will contain. The valid values for this attribute are "date", "time", and "both". The default value is "date". |
|
|
|
| |
|