Class LocalizedNumberFormatter
java.lang.Object
com.ibm.icu.number.NumberFormatterSettings<LocalizedNumberFormatter>
com.ibm.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.
- See Also:
- Status:
- Stable ICU 60.
-
Method Summary
Modifier and TypeMethodDescriptionformat(double input) Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting chain.format(long input) Format the given byte, short, int, or long to a string using the settings specified in the NumberFormatter fluent setting chain.Format the givenMeasureorCurrencyAmountto a string using the settings specified in the NumberFormatter fluent setting chain.Format the givenBigInteger,BigDecimal, or otherNumberto a string using the settings specified in the NumberFormatter fluent setting chain.com.ibm.icu.impl.number.MicroPropsformatImpl(com.ibm.icu.impl.number.DecimalQuantity fq, com.ibm.icu.impl.FormattedStringBuilder string) Deprecated.ICU 60 This API is ICU internal only.com.ibm.icu.impl.number.MicroPropsformatImpl(com.ibm.icu.impl.number.DecimalQuantity fq, MeasureUnit unit, com.ibm.icu.impl.FormattedStringBuilder string) Deprecated.ICU 67 This API is ICU internal only.getAffixImpl(boolean isPrefix, boolean isNegative) Deprecated.This API is ICU internal only.toFormat()Creates a representation of this LocalizedNumberFormat as aFormat, enabling the use of this number formatter with APIs that need an object of that type, such as MessageFormat.Disassociate the locale from this formatter.Methods inherited from class NumberFormatterSettings
decimal, displayOptions, equals, grouping, hashCode, integerWidth, macros, notation, padding, perUnit, precision, roundingMode, scale, sign, symbols, symbols, threshold, toSkeleton, unit, unitDisplayCase, unitWidth, usageModifier and TypeMethodDescriptionSets the decimal separator display strategy.displayOptions(DisplayOptions displayOptions) Specifies theDisplayOptions.booleangrouping(NumberFormatter.GroupingStrategy strategy) Specifies the grouping strategy to use when formatting numbers.inthashCode()integerWidth(IntegerWidth style) Specifies the minimum and maximum number of digits to render before the decimal mark.macros(com.ibm.icu.impl.number.MacroProps macros) Deprecated.ICU 60 This API is ICU internal only.Specifies the notation style (simple, scientific, or compact) for rendering numbers.padding(com.ibm.icu.impl.number.Padder padder) Deprecated.ICU 60 This API is ICU internal only.perUnit(MeasureUnit perUnit) Sets a unit to be used in the denominator.Specifies the rounding precision to use when formatting numbers.roundingMode(RoundingMode roundingMode) Specifies how to determine the direction to round a number when it has more digits than fit in the desired precision.Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting.sign(NumberFormatter.SignDisplay style) Sets the plus/minus sign display strategy.symbols(DecimalFormatSymbols symbols) Specifies the symbols (decimal separator, grouping separator, percent sign, numerals, etc.) to use when rendering numbers.Specifies that the given numbering system should be used when fetching symbols.Deprecated.ICU 60 This API is ICU internal only.Creates a skeleton string representation of this number formatter.unit(MeasureUnit unit) Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers.unitDisplayCase(String unitDisplayCase) Deprecated.This API is for technology preview only.Sets the width of the unit (measure unit or currency).Specifies the usage for which numbers will be formatted ("person-height", "road", "rainfall", etc.)
-
Method Details
-
format
Format the given byte, short, int, or long to a string using the settings specified in the NumberFormatter fluent setting chain.- Parameters:
input- The number to format.- Returns:
- A FormattedNumber object; call .toString() to get the string.
- See Also:
- Status:
- Stable ICU 60.
-
format
Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting chain.- Parameters:
input- The number to format.- Returns:
- A FormattedNumber object; call .toString() to get the string.
- See Also:
- Status:
- Stable ICU 60.
-
format
Format the givenBigInteger,BigDecimal, or otherNumberto a string using the settings specified in the NumberFormatter fluent setting chain.- Parameters:
input- The number to format.- Returns:
- A FormattedNumber object; call .toString() to get the string.
- See Also:
- Status:
- Stable ICU 60.
-
format
Format the givenMeasureorCurrencyAmountto 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- The number to format.- Returns:
- A FormattedNumber object; call .toString() to get the string.
- See Also:
- Status:
- Stable ICU 60.
-
toFormat
Creates a representation of this LocalizedNumberFormat as aFormat, 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(long)methods should normally be used when formatting numbers, not the Format object returned by this method.- Returns:
- A Format wrapping this LocalizedNumberFormatter.
- See Also:
- Status:
- Stable ICU 62.
-
withoutLocale
Disassociate the locale from this formatter.- Returns:
- The fluent chain.
- Status:
- Stable ICU 74.
-
formatImpl
@Deprecated public com.ibm.icu.impl.number.MicroProps formatImpl(com.ibm.icu.impl.number.DecimalQuantity fq, com.ibm.icu.impl.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- The quantity to be formatted.string- The string builder into which to insert the result.- Status:
- Internal. This API is ICU internal only.
-
formatImpl
@Deprecated public com.ibm.icu.impl.number.MicroProps formatImpl(com.ibm.icu.impl.number.DecimalQuantity fq, MeasureUnit unit, com.ibm.icu.impl.FormattedStringBuilder string) Deprecated.ICU 67 This API is ICU internal only.Version of above for unit override.- Status:
- Internal. This API is ICU internal only.
-
getAffixImpl
Deprecated.This API is ICU internal only. UseFormattedNumber.nextPosition(ConstrainedFieldPosition)for related functionality.- Status:
- Internal. This API is ICU internal only.
-