Added in API level 30

LocalizedNumberFormatter


public class LocalizedNumberFormatter
extends NumberFormatterSettings<LocalizedNumberFormatter>

java.lang.Object
   ↳ android.icu.number.NumberFormatterSettings<android.icu.number.LocalizedNumberFormatter>
     ↳ android.icu.number.LocalizedNumberFormatter


A NumberFormatter that has a locale associated with it; this means .format() methods are available. Instances of this class are immutable and thread-safe.

Summary

Public methods

FormattedNumber format(double input)

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

FormattedNumber format(Measure input)

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

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.

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.

Format toFormat()

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

Inherited methods

Public methods

format

Added in API level 30
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.

See also:

format

Added in API level 30
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.

See also:

format

Added in API level 30
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.

See also:

format

Added in API level 30
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.

See also:

toFormat

Added in API level 30
public Format toFormat ()

Creates a representation of this LocalizedNumberFormat as a 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(Measure) methods should normally be used when formatting numbers, not the Format object returned by this method.

Returns
Format A Format wrapping this LocalizedNumberFormatter.

See also: