Standard Converters in JSF (convertNumber and convertDateTime)

Standard Converters in JSF (convertNumber and convertDateTime)

The standard converters are built-in converters in JSF Framework. These converters are usually associated with the User Interface components with the help of tags that are available at http://java.sun.com/jsf/core.

There are 2 types of Standard Converters in JSF:

  • convertNumber
  • convertDateTime

convertNumber:

Attribute
Example
Currency Code < c:convertNumber type=”currency” currencyCode=”NZD” >
Currency Symbol < c:convertNumber type=”currency” currencySymbol=”$” >
maxFractionDigits < c:convertNumber maxFractionDigits=”3″ >
minFractionDigits < c:convertNumber minFractionDigits=”1″ >
maxIntegerDigits < c:convertNumber maxIntegerDigits=”3″ >
minIntegerDigits < c:convertNumber minIntegerDigits=”3″ >
integerOnly < c:convertNumber integerOnly=”true” >
pattern < c:convertNumber pattern=”#000.00″ >
type < c:convertNumber type=”percent” > (types- type=number,percent,currency)

convertDateTime

Attribute Example
type < c:convertDateTime type=”time” >
dateStyle < c:convertDateTime dateStyle=”long” > (types-short,medium,long,full)
timeStyle < c:convertDateTime type=”time” timeStyle=”long” >
pattern < c:convertDateTime pattern=”dd-MM-yy” > (types-short,medium,long,full)

Example:
converter.xhtml

Output:
output1

When date entered wrong,
output2

 

One thought on “Standard Converters in JSF (convertNumber and convertDateTime)

Leave a Reply

Your email address will not be published. Required fields are marked *