# <netui:formatNumber> Tag

A tag used to format numbers.

## Syntax

<netui:formatNumber
[country="string_country"]
[language="string_language"]
[pattern="string_simpleDataFormat"]
[type="string_type"] />

## Description

A tag used to format numbers.

The <netui:formatNumber> tag formats the output of its parent tag. For example:

        <netui:label value="{price}">
            <netui:formatNumber country="FR" language="fr" type="currency" />
        </netui:label>

The `pattern` attribute conforms to java.text.DecimalFormat pattern syntax.

The `pattern` attribute uses the comma as a grouping separater. If many different grouping sizes are specified in one `pattern`, the right-most grouping interval will be used throughout; the other grouping intervals will be ignored. For example, the following format patterns all produce the same result. If the number to format is 123456789, each will produce 123,456,789.

> - pattern="#,##,###,###"
> - pattern="######,###"
> - pattern="##,####,###"

The `type` attribute specifies three common kinds of formatting to be applied to the number. The valid values for the `type` attribute are:

> - `number`
> - `currency`
> - `percent`

The `country` attribute takes an upper-case, two-letter code as defined by ISO-3166. For a list of country codes see ISO-3166 Country Codes

The `language` attribute takes a lower-case, two-letter code as defined by ISO-639. For a list of ISO-639 language codes see ISO-639 Language Codes

## Attributes

country | Determines a formatting style for the specified country. The `country` attribute takes an uppercase, two letter code as defined by ISO-3166. For a list of country codes see ISO-3166 Country Codes
Required | Supports runtime expression evaluation | Data bindable
No | No | No
language | Determines a formatting style for the specified language. The `language` attribute is optional, but it must be set when the `country` attribute is set. The `language` attribute takes a lowercase, two letter code as defined by ISO-639. For a list of language codes see ISO-639 Language Codes
Required | Supports runtime expression evaluation | Data bindable
No | No | No
pattern | The pattern used to format the input. For detailed information on pattern syntax see java.text.DecimalFormat .
Required | Supports runtime expression evaluation | Data bindable
No | No | Read Only
type | The type of the format to apply. Possible values are `number`, `currency`, or `percent`.
Required | Supports runtime expression evaluation | Data bindable
No | No | No

## Sample

In this first example, the value "12345678" is formatted to 12,345,678.00.

        <netui:label value="12345678">
            <netui:formatNumber pattern="#,###.00" />
        </netui:label>

In the next sample, the value ".33" is formatted to 33%.

        <netui:label value=".33">
            <netui:formatNumber type="percent" />
        </netui:label>

In the next sample, the value "14.317" is formatted to $14.32.

        <netui:label value="14.317">
            <netui:formatNumber country="US" language="en" type="currency" />
        </netui:label>

## Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/formatTags/index.jsp

## Related Topics

<netui:format...> Tag Samples

<netui:formatDate> Tag

<netui:formatString> Tag

java.text.NumberFormat