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, max and min number of digits and fractional digits, grouping character or not).

The locale is taken from the locale configuration setting or the locale 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).

If the value to format is null or an empty string, no output is generated, and if a variable to hold the output is specified, it’s removed.

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

Get JavaServer Pages, 3rd 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.