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 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.