Added in API level 30

LocalizedNumberFormatter


open class LocalizedNumberFormatter : NumberFormatterSettings<LocalizedNumberFormatter!>
kotlin.Any
   ↳ 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
open FormattedNumber!
format(input: Long)

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

open FormattedNumber!
format(input: Double)

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

open FormattedNumber!
format(input: Number!)

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

open FormattedNumber!
format(input: Measure!)

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

open Format!

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 functions

Public methods

format

Added in API level 30
open fun format(input: Long): FormattedNumber!

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.
Return
FormattedNumber! A FormattedNumber object; call .toString() to get the string.

format

Added in API level 30
open fun format(input: Double): FormattedNumber!

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.
Return
FormattedNumber! A FormattedNumber object; call .toString() to get the string.

format

Added in API level 30
open fun format(input: Number!): FormattedNumber!

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.
Return
FormattedNumber! A FormattedNumber object; call .toString() to get the string.

format

Added in API level 30
open fun format(input: Measure!): FormattedNumber!

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.
Return
FormattedNumber! A FormattedNumber object; call .toString() to get the string.

toFormat

Added in API level 30
open fun toFormat(): Format!

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.

Return
Format! A Format wrapping this LocalizedNumberFormatter.