API / geotoolkit / util / NumberFormat / NumberFormat
util.NumberFormat.NumberFormat
Defines base class for formatting numbers based on Java NumberFormatter.
User can also use DecimalFormat which allows creating a custom format as well.
Example
// locale parameter can be used to specify 'Norway' as shown below. 'fr', 'ru', 'us', 'de' ... are also available.
const number = new NumberFormat({'locale': 'no'});
number.setMaximumFractionDigits(2);
number.format(5000.123); // '5 000,12'↳
NumberFormat
Constructors
Methods
Css Properties
| Name | Type | Description |
|---|---|---|
fulllocale | boolean | Specify format how to provide locale |
grouplength | number | Specify group length of numbers |
locale | string | Format locale |
locale | Locale | Format locale |
locale-locale | string | The name of the locale |
locale-numberformat | NumberFormatInfo | Defines number format |
locale-numberformat-dec | string | Defines decimal symbol |
locale-numberformat-group | string | Defines group symbol |
locale-numberformat-infinity | string | Defines infinity text |
locale-numberformat-neg | string | Defines negative symbol |
maximumfractiondigits | number | Specify maximum fraction digits |
minimumfractiondigits | number | Specify minimum fraction digits, have to be less or equal to maximumfractiondigits |
round | boolean | Round number |
Methods
▸ clone(): Format
All inheritors should implement copy constructor or provide custom implementation for this method
clone
▸ Protected copyConstructor(src): NumberFormat
copy constructor
| Name | Type | Description |
|---|---|---|
src | NumberFormat | Source to copy from |
this
▸ format(number): string
Formats number to string
| Name | Type | Description |
|---|---|---|
number | number | number to be formatted |
string
▸ getClassName(): string
string
▸ Protected getLocalFormatData(locale?): NumberFormatInfo
Return object, which contains 'dec', 'group', 'neg' symbols
| Name | Type | Description |
|---|---|---|
Optional locale | string | Locale | locale |
▸ getLocale(): Locale
Return the current locale
▸ getMaximumFractionDigits(number?): number
Return maximum faction digits
| Name | Type | Description |
|---|---|---|
Optional number | number | an optional number to get maximum fraction digits |
number
▸ getMinimumFractionDigits(number?): number
Return minimum faction digits
| Name | Type | Description |
|---|---|---|
Optional number | number | an optional number to get minimum fraction digits |
number
▸ getProperties(): OptionsOut
Gets all the properties pertaining to this object
properties pertaining to this object
▸ setLocale(locale): NumberFormat
Sets locale
| Name | Type | Description |
|---|---|---|
locale | string | Locale | locale |
this
▸ setMaximumFractionDigits(digits): NumberFormat
Return maximum fraction digits
| Name | Type | Description |
|---|---|---|
digits | number | maximum fraction digits |
this
▸ setMinimumFractionDigits(digits): NumberFormat
Return minimum fraction digits
| Name | Type | Description |
|---|---|---|
digits | number | minimum fraction digits |
this
▸ setProperties(properties?): NumberFormat
Sets properties
| Name | Type | Description |
|---|---|---|
Optional properties | Options | properties pertaining to this object |
this
▸ Protected toFixed(number, decimalPlaces?): string
Convert number to format with fixed point
| Name | Type | Description |
|---|---|---|
number | number | number to be converted |
Optional decimalPlaces | number | number of decimal places this number can have |
string
▸ Static getClassName(): string
string
▸ Static getInstance(locale?): NumberFormat
Return instance of the number format
| Name | Type | Description |
|---|---|---|
Optional locale | string | locale of formatter. Locals is not supported for now. |
instance of the number format