Name

<fmt:formatNumber>

Synopsis

The <fmt:formatNumber> action formats a numeric value according to locale-specific rules. A custom pattern can be specified, or the locale-dependent default pattern for a certain number type (currency, percentage, or a regular number) can be used as a starting point and optionally adjusted (currency code, maximum, and minimum number of digits and fractional digits, grouping character or not).

The locale is taken from the locale configuration setting or from the localization context setting. If neither is set, the locale is determined as the best match for the user preferences (Accept-Language request header).

Syntax 1: Without a body

<fmt:formatNumber value="number" 
  [pattern="pattern" |
    [type="number|currency|percent"]
    [currencyCode="currencyCode" | currencySymbol="currencySymbol"]
    [groupingUsed="true|false"]
    [minIntegerDigits="min"] [maxIntegerDigits="max"]
    [minFractionDigits="min"] [maxFractionDigits="max"]]
  [var="var" [scope="page|request|session|application"]] />

Syntax 1: With a body

<fmt:formatNumber 
  [pattern="pattern" |
    [type="number|currency|percent"]
    [currencyCode="currencyCode" | currencySymbol="currencySymbol"]
    [groupingUsed="true|false"]
    [minIntegerDigits="min"] [maxIntegerDigits="max"]
    [minFractionDigits="min"] [maxFractionDigits="max"]]
  [var="var" [scope="page|request|session|application"]]>
  number
</fmt:formatNumber>

Attributes

Attribute name

Java type

Dynamic value

accepted

Description

value

String orNumber

Yes

The value to ...

Get JavaServer Pages, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.