Tobago Demo

Menu

Conversion

To convert numbers put a <f:convertNumber/> tag in an component.

Example

The following examples show the basic functions of the number converter. The given number is in every example:

Default

By default, grouping is activated and only three digits after the point are shown. Also the value of type is 'number'.

<tc:out label="Number" markup="number" value="#{conversionController.amount}"> <f:convertNumber/> </tc:out> 7,200,000.988

Grouping

Grouping is deactivated.

<f:convertNumber groupingUsed="false"/> 7200000.988

Integer only

Only integer values are shown.

<f:convertNumber integerOnly="true"/> 7,200,000.988

Minimal Digits

There are at minimum 10 integer digits and 5 digits after the point shown. The given amount is not high enough in both ways.

<f:convertNumber minIntegerDigits="10" minFractionDigits="5"/> 0,007,200,000.98760

Maximal Digits

There are maximal 6 integer digits and 2 digits after the point shown. Notice, that the second digit after the point is rounded up.

<f:convertNumber maxIntegerDigits="6" maxFractionDigits="2"/> 200,000.99

Type

The type attribute can have the value 'number' (default), 'currency' and 'percent'. If the type is set to 'currency', a code or a symbol must be set. Have a look at the following examples.

Currency Code

The currency code is set to 'EUR'. Also the type must set to 'currency', otherwise the currencyCode attribute has no effect.

<f:convertNumber type="currency" currencyCode="EUR"/> EUR7,200,000.99

Currency Symbol

The currency symbol is set to '€'. Also the type must set to 'currency', otherwise the currencyCode attribute has no effect.

<f:convertNumber type="currency" currencySymbol="€"/> €7,200,000.99

Percent

The type is set to 'percent'.

<f:convertNumber type="percent"/> 720,000,099%
© 2005-2023 Apache Software Foundation, Licensed under the Apache License, Version 2.0.