Top Description Fields Constructors Methods
com.ibm.icu.number

public Class LocalizedNumberFormatter

extends NumberFormatterSettings<LocalizedNumberFormatter>
Class Inheritance
Imports
java.math.BigInteger, java.text.Format, java.util.Objects, java.util.concurrent.atomic.AtomicLongFieldUpdater, com.ibm.icu.impl.FormattedStringBuilder, .StandardPlural, com.ibm.icu.impl.number.DecimalQuantity, .DecimalQuantity_DualStorageBCD, .LocalizedNumberFormatterAsFormat, .MacroProps, .MicroProps, com.ibm.icu.math.BigDecimal, com.ibm.icu.util.CurrencyAmount, .Measure, .MeasureUnit

A NumberFormatter that has a locale associated with it; this means .format() methods are available. Instances of this class are immutable and thread-safe.
ICU Status
Stable since ICU 60.
See Also
NumberFormatter

Field Summary

Modifier and TypeField and Description
pack-priv static final AtomicLongFieldUpdater<LocalizedNumberFormatter>
pack-priv volatile long
pack-priv volatile NumberFormatterImpl
pack-priv volatile LocalizedNumberFormatter
Inherited from com.ibm.icu.number.NumberFormatterSettings:
KEY_DECIMALKEY_GROUPINGKEY_INTEGERKEY_LOCALEKEY_MACROSKEY_MAXKEY_NOTATIONKEY_PADDERKEY_PER_UNITKEY_PRECISIONKEY_ROUNDING_MODEKEY_SCALEKEY_SIGNKEY_SYMBOLSKEY_THRESHOLDKEY_UNITKEY_UNIT_DISPLAY_CASEKEY_UNIT_WIDTHKEY_USAGE

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private boolean
pack-priv LocalizedNumberFormatter
public FormattedNumber

Returns:

A FormattedNumber object; call .toString() to get the string.
format
(long
The number to format.
input
)

Format the given byte, short, int, or long to a string using the settings specified in the NumberFormatter fluent setting chain.

public FormattedNumber

Returns:

A FormattedNumber object; call .toString() to get the string.
format
(double
The number to format.
input
)

Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting chain.

public FormattedNumber

Returns:

A FormattedNumber object; call .toString() to get the string.
format
(Number
The number to format.
input
)

Format the given BigInteger, BigDecimal, or other Number to a string using the settings specified in the NumberFormatter fluent setting chain.

public FormattedNumber

Returns:

A FormattedNumber object; call .toString() to get the string.
format
(Measure
The number to format.
input
)

Format the given Measure or CurrencyAmount to a string using the settings specified in the NumberFormatter fluent setting chain.

private FormattedNumber
format(DecimalQuantity fq)

Deprecated as a consequence of DecimalQuantity being deprecated.
Helper method that creates a FormattedStringBuilder and formats.
public MicroProps
formatImpl(DecimalQuantity
The quantity to be formatted.
fq
,
FormattedStringBuilder
The string builder into which to insert the result.
string
)

Deprecated ICU 60 This API is ICU internal only.
This is the core entrypoint to the number formatting pipeline.
public MicroProps
formatImpl(DecimalQuantity fq, MeasureUnit unit, FormattedStringBuilder string)

Deprecated ICU 67 This API is ICU internal only.
Version of above for unit override.
public String
getAffixImpl(boolean isPrefix, boolean isNegative)

Deprecated This API is ICU internal only.
public Format

Returns:

A Format wrapping this LocalizedNumberFormatter.
toFormat
()

Creates a representation of this LocalizedNumberFormat as a java.text.Format, enabling the use of this number formatter with APIs that need an object of that type, such as MessageFormat.

Inherited from com.ibm.icu.number.NumberFormatterSettings:
decimaldisplayOptionsequalsgroupinghashCodeintegerWidthmacrosnotationpaddingperUnitprecisionresolveroundingModescalesignsymbolssymbolsthresholdtoSkeletonunitunitDisplayCaseunitWidthusage

Field Detail

callCountback to summary
pack-priv static final AtomicLongFieldUpdater<LocalizedNumberFormatter> callCount
callCountInternalback to summary
pack-priv volatile long callCountInternal
compiledback to summary
pack-priv volatile NumberFormatterImpl compiled
savedWithUnitback to summary
pack-priv volatile LocalizedNumberFormatter savedWithUnit

Constructor Detail

LocalizedNumberFormatterback to summary
pack-priv LocalizedNumberFormatter(NumberFormatterSettings<?> parent, int key, Object value)

Method Detail

computeCompiledback to summary
private boolean computeCompiled()
createback to summary
pack-priv LocalizedNumberFormatter create(int key, Object value)

Implements abstract com.ibm.icu.number.NumberFormatterSettings.create.

Annotations
@Override
formatback to summary
public FormattedNumber format(long input)

Format the given byte, short, int, or long to a string using the settings specified in the NumberFormatter fluent setting chain.

Parameters
input:long

The number to format.

Returns:FormattedNumber

A FormattedNumber object; call .toString() to get the string.

ICU Status
Stable since ICU 60.
See Also
NumberFormatter
formatback to summary
public FormattedNumber format(double input)

Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting chain.

Parameters
input:double

The number to format.

Returns:FormattedNumber

A FormattedNumber object; call .toString() to get the string.

ICU Status
Stable since ICU 60.
See Also
NumberFormatter
formatback to summary
public FormattedNumber format(Number input)

Format the given BigInteger, BigDecimal, or other Number to a string using the settings specified in the NumberFormatter fluent setting chain.

Parameters
input:Number

The number to format.

Returns:FormattedNumber

A FormattedNumber object; call .toString() to get the string.

ICU Status
Stable since ICU 60.
See Also
NumberFormatter
formatback to summary
public FormattedNumber format(Measure input)

Format the given Measure or CurrencyAmount to a string using the settings specified in the NumberFormatter fluent setting chain.

The unit specified here overrides any unit that may have been specified in the setter chain. This method is intended for cases when each input to the number formatter has a different unit.

Parameters
input:Measure

The number to format.

Returns:FormattedNumber

A FormattedNumber object; call .toString() to get the string.

ICU Status
Stable since ICU 60.
See Also
NumberFormatter
formatback to summary
private FormattedNumber format(DecimalQuantity fq)

Deprecated

as a consequence of DecimalQuantity being deprecated. See corresponding docs for further information.

Helper method that creates a FormattedStringBuilder and formats.

formatImplback to summary
public MicroProps formatImpl(DecimalQuantity fq, FormattedStringBuilder string)

Deprecated

ICU 60 This API is ICU internal only.

This is the core entrypoint to the number formatting pipeline. It performs self-regulation: a static code path for the first few calls, and compiling a more efficient data structure if called repeatedly.

This function is very hot, being called in every call to the number formatting pipeline.

Parameters
fq:DecimalQuantity

The quantity to be formatted.

string:FormattedStringBuilder

The string builder into which to insert the result.

Annotations
@Deprecated
ICU Status
Internal ICU component.
formatImplback to summary
public MicroProps formatImpl(DecimalQuantity fq, MeasureUnit unit, FormattedStringBuilder string)

Deprecated

ICU 67 This API is ICU internal only.

Version of above for unit override.

Annotations
@Deprecated
ICU Status
Internal ICU component.
getAffixImplback to summary
public String getAffixImpl(boolean isPrefix, boolean isNegative)

Deprecated

This API is ICU internal only. Use FormattedNumber#nextPosition for related functionality.

Annotations
@Deprecated
ICU Status
Internal ICU component.
toFormatback to summary
public Format toFormat()

Creates a representation of this LocalizedNumberFormat as a java.text.Format, enabling the use of this number formatter with APIs that need an object of that type, such as MessageFormat.

This API is not intended to be used other than for enabling API compatibility. The format methods should normally be used when formatting numbers, not the Format object returned by this method.

Returns:Format

A Format wrapping this LocalizedNumberFormatter.

ICU Status
Stable since ICU 62.
See Also
NumberFormatter