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


Contents
|
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 |
Enumerated |
| |
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 |
|
| locale |
Enumerated |
| |
| The locale attribute sets the language, country, and variant for formatting locale-sensitive data such as numbers and dates. If not specified, the Locale returned by FacesContext.getViewRoot().getLocale() will be used. Valid expressions must evaluate to a java.util.Locale. |
| pattern |
Enumerated |
| |
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 |
Enumerated |
| |
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 |
Enumerated |
| |
| 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 |
Enumerated |
| |
| 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". |
|
|
|
| |
|