Caplin Trader 5.0.0

Class: module:ct-element/formatter/LocalisedAmountFormatter

module:ct-element/formatter/LocalisedAmountFormatter()

new module:ct-element/formatter/LocalisedAmountFormatter()

Formats a number into a localised string representation.

LocalisedAmountFormatter Formats a number to a configurable number of decimal places according to current locale of browser. It automatically detects the current locale of the the browser and uses that to format numbers. For example
1234567.89 = 1,234,567.89 in english locale
1234567.89 = 1.234.567,89 in french locale
It is typically used in the XML Renderer Framework, but can be invoked programmatically:

LocalisedAmountFormatter.format(1234567890, {}) LocalisedAmountFormatter.format(1234567890, {dp: 4})
Implements:

Methods

format(vValue, mAttributes) → {String}

Formats a number into an localised string representation.

Parameters:
Name Type Description
vValue Number

the numeric amount (if a string is passed it is returned unchanged).

mAttributes Map

a list of attributes.

Properties
Name Type Description
dp Number

number of decimal places to be displayed. Rounding occurs according to standard javascript behaviour.

Implements:
Returns:

the tokenized amount.

Type
String