Class Index | File Index

Classes


Class NumFmt

Create a new number formatter instance. Locales differ in the way that digits in a formatted number are grouped, in the way the decimal character is represented, etc. Use this formatter to get it right for any locale.

This formatter can format plain numbers, currency amounts, and percentage amounts.

As with all formatters, the recommended practice is to create one formatter and use it multiple times to format various numbers.

The options can contain any of the following properties:


Defined in: ilib-full-dyn.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
NumFmt(options)
Method Summary
Method Attributes Method Name and Description
 
format(num)
Format a number according to the settings of this number formatter instance.
<static>  
Return an array of available locales that this formatter can format
 
Returns the ISO 4217 code for the currency that this formatter formats.
 
Return the locale for this formatter instance.
 
Returns the maximum fraction digits set up in the constructor.
 
Returns the minimum fraction digits set up in the constructor.
 
Returns the rounding mode set up in the constructor.
 
If this formatter is a currency formatter, then the style determines how the currency is denoted in the formatted output.
 
Return the type of formatter.
 
Return true if this formatter uses native digits to format the number.
 
Returns true if this formatter groups together digits in the integral portion of a number, based on the options set up in the constructor.
Class Detail
NumFmt(options)
Parameters:
{Object.<string|*>} options
A set of options that govern how the formatter will behave
Method Detail
{string} format(num)
Format a number according to the settings of this number formatter instance.
Parameters:
num
{number|string|INumber|Number} a floating point number to format
Returns:
{string} a string containing the formatted number

<static> {Array.<Locale>|undefined} NumFmt.getAvailableLocales()
Return an array of available locales that this formatter can format
Returns:
{Array.<Locale>|undefined} an array of available locales

{string} getCurrency()
Returns the ISO 4217 code for the currency that this formatter formats. IF the typeof this formatter is not "currency", then this method will return undefined.
Returns:
{string} the ISO 4217 code for the currency that this formatter formats, or undefined if this not a currency formatter

{Locale} getLocale()
Return the locale for this formatter instance.
Returns:
{Locale} the locale instance for this formatter

{number} getMaxFractionDigits()
Returns the maximum fraction digits set up in the constructor.
Returns:
{number} the maximum number of fractional digits this formatter will format, or -1 for no maximum

{number} getMinFractionDigits()
Returns the minimum fraction digits set up in the constructor. If the formatter has the type "currency", then the minimum fraction digits is the amount of digits that is standard for the currency in question unless overridden in the options to the constructor.
Returns:
{number} the minimum number of fractional digits this formatter will format, or -1 for no minimum

{string} getRoundingMode()
Returns the rounding mode set up in the constructor. The rounding mode controls how numbers are rounded when the integral or fraction digits of a number are limited.
Returns:
{string} the name of the rounding mode used in this formatter

{string} getStyle()
If this formatter is a currency formatter, then the style determines how the currency is denoted in the formatted output. This method returns the style that this formatter will produce. (See the constructor comment for more about the styles.)
Returns:
{string} the name of the style this formatter will use to format currency amounts, or "undefined" if this formatter is not a currency formatter

{string} getType()
Return the type of formatter. Valid values are "number", "currency", and "percentage".
Returns:
{string} the type of formatter

{boolean} getUseNative()
Return true if this formatter uses native digits to format the number. If the useNative option is given to the constructor, then this flag will be honoured. If the useNative option is not given to the constructor, this this formatter will use native digits if the locale typically uses native digits.
Returns:
{boolean} true if this formatter will format with native digits, false otherwise

{boolean} isGroupingUsed()
Returns true if this formatter groups together digits in the integral portion of a number, based on the options set up in the constructor. In most western European cultures, this means separating every 3 digits of the integral portion of a number with a particular character.
Returns:
{boolean} true if this formatter groups digits in the integral portion of the number

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Feb 02 2016 15:53:55 GMT-0800 (PST)