Skip to content
Reference > Methods

formatNumber(value,format,options)

Definition

String formatNumber(Number value, String format, String options)

Description

Converts a numeric value to string based on the supplied format.

Parameter Definition

Name Type Description
value Number value to convert to string
format String pattern for converting value. See java DecimalFormat for details
options String Place holder, leave as empty string

Examples

1
2
3
4
String r1 = formatNumber(123.456D,"#",""); // r1 == 123
String r2 = formatNumber(123.456D,"#,###",""); // r2 == 123
String r3 = formatNumber(123.456D,"#,###.000",""); // r3 == 123.456
String r4 = formatNumber(123.456D,"#,###.E0",""); // r4 == 123.5E0