Caplin Trader 4.8.0

Class: module:caplin/element/formatter/ThousandsFormatter

module:caplin/element/formatter/ThousandsFormatter

Constructor

new module:caplin/element/formatter/ThousandsFormatter()

Adds a separator character for each 'thousand' position in a 1234567.890 eg 1000000 becomes 1,000,000

This formatter must be run after the DecimalFormatter, otherwise different locale formats for decimal places may confuse the DecimalFormatter.

The following attributes are required by the renderer:

  • separator - the character to use as a thousands separator

ThousandsFormatter is a flyweight singleton, and therefore this constructor should never be invoked directly.

Instead, it is instantiated by the RendererFactory, which reads RendererType specifications from XML and instantiates the formatters by name.

Implements:

Methods

format(sValue, mAttributes) → {String}

Adds a separator character for each 'thousand' position in a number. eg 1000000 becomes 1,000,000
Parameters:
Name Type Description
sValue String The field value
mAttributes Map The renderer attributes
Returns:
The formatted value
Type
String

toString() → {String}

Returns a human-readable string representation of the object, which is useful for debugging.
Implements:
  • module:caplin/element/Formatter#toString
Returns:
The string representation
Type
String