Converts the specified number to a string according to the specified formatting pattern.

The Java implementation of this function uses java.text.DecimalFormat class of the standard Java API and basically looks as the following:


NumberFormat f = new DecimalFormat (pattern);
return f.format (value);
For the detailed syntax of the formatting pattern, please, consult the Java API documentation for this class (available at Java Technology website: http://java.sun.com/).

Here, we provide only the table of Special Pattern Characters copied from that documentation:
Symbol Location Localized Meaning
0 Number Yes Digit
# Number Yes Digit, zero shows as absent
. Number Yes Decimal separator or monetary decimal separator
- Number Yes Minus sign
, Number Yes Grouping separator
E Number Yes Separates mantissa and exponent in scientific notation. Need not be quoted in prefix or suffix.
; Subpattern boundary Yes Separates positive and negative subpatterns
% Prefix or suffix Yes Multiply by 100 and show as percentage
\u2030 Prefix or suffix Yes Multiply by 1000 and show as per mille value
¤
(\u00A4)
Prefix or suffix No Currency sign, replaced by currency symbol. If doubled, replaced by international currency symbol. If present in a pattern, the monetary decimal separator is used instead of the decimal separator.
' Prefix or suffix No Used to quote special characters in a prefix or suffix, for example, "'#'#" formats 123 to "#123". To create a single quote itself, use two in a row: "# o''clock".

Parameters:

value

The numeric value to be formatted.
pattern
The formatting pattern.

If not specified or empty string, the following pattern is used by default: #,##0.00

Note: If the specified pattern is invalid, the function will raise an error.

Tip:

You may call this function in a more method-like style:

value.format(pattern)