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
Result: 1.23
Two decimal places, integer input
Result: 123.00
Zero will pad zeros; nine doesn’t
Result: 00123/ 123
show positive/negative sign
Result: +5/-5
Formats to a dollar format (US)
You could use dollarFormat() or lsCurrencyFormat() instead
Result: 1,2,3,4,5,6,7,8,9.00$
Additional Examples
Related
Last updated
Was this helpful?
