pp108 : NumberFormat

NumberFormat

This component enables the number to be formatted according to the locale.

The following table lists the methods that can be defined for the component:

Method

Description

format

Formats the value according to the locale

setLocale

Sets the Locale object on the NumberFormat

getLocale

Returns the Locale object on the NumberFormat

Example

This sample displays the use of the NumberFormat library. 

var locale = new Locale("en-US");
locale.setDecimalSeparator(",");
locale.setGroupSeparator(" ");
locale.setNumberGroupSizes("2,3");
var numberFormat = new NumberFormat();
numberFormat.setLocale(locale);
numberFormat.format("123504.36");//Will return "1 235 04,36"