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 |
|
Methods and Properties |
|
Since |
2019.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string |
optional |
Indicates the group separator. |
2019.2 |
|
string |
optional |
Indicates the decimal separator. |
2019.2 |
|
number |
optional |
Indicates the precision. |
2019.2 |
|
enum |
optional |
Indicates the negative number format. |
2019.2 |
|
string |
optional |
Indicates the locale from which default settings are determined. The other |
2021.1 |
Syntax
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 |