Caplin Trader 4.8.0

Class: module:caplin/element/formatter/LeadingZeroFormatter

module:caplin/element/formatter/LeadingZeroFormatter

Constructor

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

Pads the integer part of a number with as many leading zeros needed to reach the specified length.

LeadingZeroFormatter is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following example which evaluates to '0089':

caplin.element.formatter.LeadingZeroFormatter.format(89, {length:4})
Implements:

Methods

format(vValue, mAttributes) → {String}

Pads the integer part of a number with as many leading zeros needed to reach the specified size.
Parameters:
Name Type Description
vValue String | Number the number.
mAttributes Map the map of attributes.
Properties
Name Type Attributes Default Description
langth Number <optional>
0 the minimum size of the padded number.
Returns:
the number, padded to the required length with leading zeros.
Type
String