Caplin Trader 4.8.0

Class: module:caplin/element/formatter/AmountFormatter

module:caplin/element/formatter/AmountFormatter

Constructor

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

Formats a number into an amount with a thousands, millions or billions token.

AmountFormatter is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following example which evaluates to '1.23456789B' and '1.230B' respectively:

caplin.element.formatter.AmountFormatter.format(1234567890, {}) caplin.element.formatter.AmountFormatter.format(1234567890, {dp: 4})
Implements:

Methods

format(vValue, attributes) → {String}

Formats a number into an amount with a thousands, millions or billions token.
Parameters:
Name Type Description
vValue Variant the numeric amount (String or Number type).
attributes Map a list of attributes, as specified here and in module:caplin/element/formatter/RoundingFormatter.
Properties
Name Type Attributes Default Description
thousands String <optional>
'K' token representing thousands
millions String <optional>
'M' token representing millions
billions String <optional>
'B' token representing billions
Returns:
the tokenized amount.
Type
String