Skip to content

API / geotoolkit / util / DecimalFormat / DecimalFormat

Class: 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'.

Hierarchy

Table of contents

Constructors
  • [new DecimalFormat(options)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.util.decimalformat.decimalformat.md#new decimalformat(options))
Methods
Css Properties
Name Type Description
autodetectpercentagebooleanAutodetectpercentage
decimalseparatoralwaysshownbooleanDecimalseparatoralwaysshown
formatstringFormat : 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>
fulllocalebooleanSpecify format how to provide locale
grouplengthnumberSpecify group length of numbers
ispercentagebooleanIspercentage
localestringFormat locale
localeLocaleFormat locale
locale-localestringThe name of the locale
locale-numberformatNumberFormatInfoDefines number format
locale-numberformat-decstringDefines decimal symbol
locale-numberformat-groupstringDefines group symbol
locale-numberformat-infinitystringDefines infinity text
locale-numberformat-negstringDefines negative symbol
maximumfractiondigitsnumberSpecify maximum fraction digits
minimumfractiondigitsnumberSpecify minimum fraction digits, have to be less or equal to maximumfractiondigits
overridedecsepstringDecimal separator
overridegroupsepstringOverridegroupsep
overridenegsignstringOverridenegsign
roundbooleanRound number

Contents

Constructors

new DecimalFormat(options)

• new DecimalFormat(options?)

Parameters

Name Type
Optional optionsOptions

Overrides

NumberFormat.constructor

Methods

clone

▸ clone(): Format

All inheritors should implement copy constructor or provide custom implementation for this method

Returns

Format

clone

Inherited from

NumberFormat.clone


copyConstructor

▸ Protected copyConstructor(src): DecimalFormat

copy constructor

Parameters

Name Type Description
srcDecimalFormatSource to copy from

Returns

DecimalFormat

this instance, filled with properties copied from the given src

Overrides

NumberFormat.copyConstructor


format

▸ format(number): string

Formats number to string

Parameters

Name Type Description
numbernumbernumber to be formatted

Returns

string

Overrides

NumberFormat.format


getClassName

▸ getClassName(): string

Returns

string

Inherited from

NumberFormat.getClassName


getLocalFormatData

▸ Protected getLocalFormatData(locale?): NumberFormatInfo

Return object, which contains 'dec', 'group', 'neg' symbols

Parameters

Name Type Description
Optional localestring | Localelocale

Returns

NumberFormatInfo

Inherited from

NumberFormat.getLocalFormatData


getLocale

▸ getLocale(): Locale

Return the current locale

Returns

Locale

Inherited from

NumberFormat.getLocale


getMaximumFractionDigits

▸ getMaximumFractionDigits(number?): number

Return maximum faction digits

Parameters

Name Type Description
Optional numbernumberan optional number to get maximum fraction digits

Returns

number

Inherited from

NumberFormat.getMaximumFractionDigits


getMinimumFractionDigits

▸ getMinimumFractionDigits(number?): number

Return minimum faction digits

Parameters

Name Type Description
Optional numbernumberan optional number to get minimum fraction digits

Returns

number

Inherited from

NumberFormat.getMinimumFractionDigits


getProperties

▸ getProperties(): OptionsOut

Gets all the properties pertaining to this object

Returns

OptionsOut

properties pertaining to this object

Overrides

NumberFormat.getProperties


setLocale

▸ setLocale(locale): DecimalFormat

Sets locale

Parameters

Name Type Description
localestring | Localelocale

Returns

DecimalFormat

this

Inherited from

NumberFormat.setLocale


setMaximumFractionDigits

▸ setMaximumFractionDigits(digits): DecimalFormat

Return maximum fraction digits

Parameters

Name Type Description
digitsnumbermaximum fraction digits

Returns

DecimalFormat

this

Inherited from

NumberFormat.setMaximumFractionDigits


setMinimumFractionDigits

▸ setMinimumFractionDigits(digits): DecimalFormat

Return minimum fraction digits

Parameters

Name Type Description
digitsnumberminimum fraction digits

Returns

DecimalFormat

this

Inherited from

NumberFormat.setMinimumFractionDigits


setProperties

▸ setProperties(properties?): DecimalFormat

Sets properties

Parameters

Name Type Description
Optional propertiesOptionsproperties pertaining to this object

Returns

DecimalFormat

this

Overrides

NumberFormat.setProperties


toFixed

▸ Protected toFixed(number, decimalPlaces?): string

Convert number to format with fixed point

Parameters

Name Type Description
numbernumbernumber to be converted
Optional decimalPlacesnumbernumber of decimal places this number can have

Returns

string

Inherited from

NumberFormat.toFixed


getClassName

▸ Static getClassName(): string

Returns

string

Inherited from

NumberFormat.getClassName


getDefault

▸ Static getDefault(): DecimalFormat

Return default decimal format

Returns

DecimalFormat


getInstance

▸ Static getInstance(locale?): NumberFormat

Return instance of the number format

Parameters

Name Type Description
Optional localestringlocale of formatter. Locals is not supported for now.

Returns

NumberFormat

instance of the number format

Inherited from

NumberFormat.getInstance