API / geotoolkit / util / DecimalFormat / DecimalFormat
util.DecimalFormat.DecimalFormat
Defines class for formatting decimal numbers
Example
const df = new DecimalFormat( {'format':"#,###,##0.00"} ); //df.format(364565.14) gives "364,565.14"Example
const df = new DecimalFormat( {'format':"#,###,##0.000", 'locale': 'ru'} ); //df.format(364565.14) gives '364 565,140'Example
const df = new DecimalFormat( {'format':"0.####E0"}); //df.format(364565.14) gives '3.6457E5'Example
// The code below shows how to replace decimal separator to be a comma ',' without having to specify a local of a country that uses ',' comma.
// It changes 'overridedecsep' property and overridegroupsep for group separator.
const df = new DecimalFormat({'format':"###,###.###", overridedecsep: ',', overridegroupsep: ''});
const str = df.format(12345.6); // 'str' should be '12345,6'.↳
DecimalFormat
Constructors
Methods
Css Properties
| Name | Type | Description |
|---|---|---|
autodetectpercentage | boolean | Autodetectpercentage |
decimalseparatoralwaysshown | boolean | Decimalseparatoralwaysshown |
format | string | Format : The syntax for the formatting is:<br> 0 = Digit<br> |
| = Negative sign<br> , = Grouping Separator<br> % = Percent (multiplies the number by 100)<br> E = Separates mantissa and exponent in scientific notation. Need not be quoted in prefix or suffix.<br> | ||
fulllocale | boolean | Specify format how to provide locale |
grouplength | number | Specify group length of numbers |
ispercentage | boolean | Ispercentage |
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 |
overridedecsep | string | Decimal separator |
overridegroupsep | string | Overridegroupsep |
overridenegsign | string | Overridenegsign |
round | boolean | Round number |
Methods
▸ clone(): Format
All inheritors should implement copy constructor or provide custom implementation for this method
clone
▸ Protected copyConstructor(src): DecimalFormat
copy constructor
| Name | Type | Description |
|---|---|---|
src | DecimalFormat | Source to copy from |
this instance, filled with properties copied from the given src
▸ 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 |
NumberFormat.getLocalFormatData
▸ 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
NumberFormat.getMaximumFractionDigits
▸ getMinimumFractionDigits(number?): number
Return minimum faction digits
| Name | Type | Description |
|---|---|---|
Optional number | number | an optional number to get minimum fraction digits |
number
NumberFormat.getMinimumFractionDigits
▸ getProperties(): OptionsOut
Gets all the properties pertaining to this object
properties pertaining to this object
▸ setLocale(locale): DecimalFormat
Sets locale
| Name | Type | Description |
|---|---|---|
locale | string | Locale | locale |
this
▸ setMaximumFractionDigits(digits): DecimalFormat
Return maximum fraction digits
| Name | Type | Description |
|---|---|---|
digits | number | maximum fraction digits |
this
NumberFormat.setMaximumFractionDigits
▸ setMinimumFractionDigits(digits): DecimalFormat
Return minimum fraction digits
| Name | Type | Description |
|---|---|---|
digits | number | minimum fraction digits |
this
NumberFormat.setMinimumFractionDigits
▸ setProperties(properties?): DecimalFormat
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 getDefault(): DecimalFormat
Return default decimal format
▸ 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