format.getNumberFormatter(options)

Method Description

Creates a format.NumberFormatter object to format numbers to strings.

Returns

Object

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

10 units

Module

N/format/i18n Module

Methods and Properties

N/format/i18n Module Members

Since

2019.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.groupSeparator

string

optional

Indicates the group separator.

2019.2

options.decimalSeparator

string

optional

Indicates the decimal separator.

2019.2

options.precision

number

optional

Indicates the precision.

2019.2

options.negativeNumberFormat

enum

optional

Indicates the negative number format.

2019.2

options.locale

string

optional

Indicates the locale from which default settings are determined. The other format.getNumberFormatter(options) parameters can override this parameter.

2021.1

Syntax

Important:

The following code snippet shows the syntax for this member. It is not a functional example. For a complete script example, see N/format/i18n Module Script Samples.

            // Add additional code
... 
    // no parameter given so the default number formatter object returned which can be parsed
    var numberFormatter = format.getNumberFormatter(); 
        
    var gs = numberFormatter.groupSeparator;         // gs is ','
    var ds = numberFormatter.decimalSeparator;       // ds is '.'
    var precision = numberFormatter.precision;       // precision is '2'
    var nnf = numberFormatter.negativeNumberFormat;  // nnf is 'BRACKETS'

    // using the options/parameters
    var numFormatter2 = format.getNumberFormatter({
        groupSeparator: " ",
        decimalSeparator: ",", 
        precision: 2, 
        negativeNumberFormat: format.NegativeNumberFormat.MINUS
    });
...
// Add additional code 

          

Errors

Error Code

Thrown If

INVALID_LOCALE

The locale parameter is not valid

SSS_INVALID_TYPE_ARG

The parameter type is wrong

Related Topics

General Notices