For the complete documentation index, see llms.txt. This page is also available as Markdown.

NumberFormat

Formats a number with an optional format mask

Method Signature

NumberFormat(number=[any], mask=[string], locale=[string])

Arguments

Argument
Type
Required
Description
Default

number

any

true

The number to be formatted, or an empty string which will be treated as 0.

mask

string

false

The formatting mask to apply using the {@link java.text.DecimalFormat} patterns.

locale

string

false

An optional locale string to apply to the format

Examples

Format to 2 decimal places

<!--- 1234.00 ---><bx:output>1.234 ('__.00') ->  <!--- 1.23 --->#numberFormat( 1.234, "__.00" )#<br/> 
1234 ('__.00') -> #numberFormat( 1234, "__.00" )#<br/> </bx:output>

0 and 9 mask

<bx:output>
123 ('00000') -> #numberFormat( 123, "00000" )#<br/>
123 ('99999') -> #numberFormat( 123, "99999" )#<br/>
123 ('99.99999') -> #numberFormat( 123.12, "99.99999" )#<br/>
</bx:output>

_ mask

+ & - mask

, comma

L,C mask

Two decimal places, decimal input

Run Example

Result: 1.23

Two decimal places, integer input

Run Example

Result: 123.00

Zero will pad zeros; nine doesn’t

Run Example

Result: 00123/ 123

show positive/negative sign

Run Example

Result: +5/-5

Formats to a dollar format (US)

You could use dollarFormat() or lsCurrencyFormat() instead

Run Example

Result: 1,2,3,4,5,6,7,8,9.00$

Additional Examples

Run Example

Last updated

Was this helpful?