Name

<f:convertDateTime>

Synopsis

This action creates an instance of the converter registered with the ID javax.faces.DateTime, configures it based on the action attributes and associates the converter instance with the component represented by the closest JSF component parent action element.

Syntax

<f:convertDateTime 
  [dateStyle="default|short|medium|long|full"] 
  [timeStyle="default|short|medium|long|full"]
  [pattern="pattern"]
  [type="time|date|both"]
  [locale="locale"]
  [timeZone="timeZone"]
/>

Attributes

Attribute name

Java type

EL expression type

Description

dateStyle
String

Any

One of the predefined locale-dependent date patterns.

locale
String or java.util.Locale

Any

A locale to be used instead of the default.

pattern
String

Any

A custom pattern in the form accepted by java.text.SimpleDateFormat (see the next table).

timeStyle
String

Any

One of the predefined locale-dependent time patterns.

timeZone
String or java.util.
TimeZone

Any

The time zone to use instead of the default.

type
String

Any

Which portions to format or parse. Defaults to time if timeStyle is set, to date if dateStyle is set, or to both if both style attributes are set.

The symbols that can be used in a custom pattern, set by the pattern attribute, are the same as those supported by the java.text.SimpleDateFormat:

Symbol

Description

Presentation format

Example

G

Era designator

Text

AD

y

Year

Number

2002

M

Month in year

Text or number

May or 05

d

Day in month

Number

16

Get JavaServer Faces now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.