Documentation
JSFToolbox

Search 

Contents

  1. Introduction
  2. Getting Started
  3. Developing Web Sites
  4. Using Components
  5. Internationalization
  6. Code View Support
  7. Design View Support
  8. Keyboard Shortcuts
  9. Tag Object Toolbars
  10. JSF Server Behaviors
  11. Property Inspectors
Selected 12. JSF Tag Reference

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
defaultJan 1, 2006 1:20:45 PM
short1/1/06 1:20:45 PM
mediumJan 1, 2006 1:20:45 PM
longJanuary 1, 2006 1:20:45 PM
fullSunday, 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.                                                                                                                                                                                                                                                                                                                  
PatternResult
yyyy.MM.dd 'at' HH:mm:ss z2006.01.01 at 10:05:30 EST
EEE, MMM d, ''yySun, Jan 1, '06
h:mm a10:05 AM
hh 'o''clock' a, zzzz10 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
defaultJan 1, 2006 10:05:30 AM
short1/1/06 10:05:30 AM
mediumJan 1, 2006 10:05:30 AM
longJanuary 1, 2006 10:05:30 AM
fullSunday, 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".