Caplin Trader 4.7.1

Class: module:caplin/element/formatter/DateFormatter

module:caplin/element/formatter/DateFormatter

Constructor

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

Formats a date value by converting it from a specified input format to a new output format.

DateFormatter is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following examples which evaluate to '09-Sep-2001 01:46:40' and '2001Sep09' respectively:

caplin.element.formatter.DateFormatter.format(1e12, {inputFormat:'U'})
caplin.element.formatter.DateFormatter.format(1e12, {inputFormat:'U', outputFormat:'YMd'})

See module:caplin/element/parser/DateParser for the complementary parser.

Implements:

Methods

format(vValue, mAttributes) → {String}

Formats a date by converting it from a specified input format to a new output format.
Parameters:
Name Type Description
vValue Variant the input date (String or Date type).
mAttributes Map the map of attributes.
Properties
Name Type Attributes Default Description
inputFormat String <optional>
DD-MM-YYYY HH:mm:ss format of the input date, expressed with Moment.js format tokens.
outputFormat String <optional>
DD-MM-YYYY HH:mm:ss format of the output date, expressed with Moment.js format tokens.
adjustForTimezone String <optional>
value representing whether the formatter should adjust the date according to the client's timezone.
Returns:
the output date.
Type
String