Caplin Trader 4.8.0

Class: module:br/formatting/LeadingZeroFormatter

module:br/formatting/LeadingZeroFormatter

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

LeadingZeroFormatter is typically used with Presenter, but can be invoked programmatically as in the following example which evaluates to "0089":

br.formatting.LeadingZeroFormatter.format(89, {length:4})

Constructor

new module:br/formatting/LeadingZeroFormatter()

Implements:

Methods

format(vValue, mAttributes)

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

Attribute Options:

Option Description
size the minimum size of the padded number (defaults to zero)
Parameters:
Name Type Description
vValue Variant the number (String or Number type).
mAttributes Map the map of attributes.
Implements:
Returns:
the number, padded to the required length with leading zeros.