Added in API level 30

LocalizedNumberRangeFormatter


public class LocalizedNumberRangeFormatter
extends NumberRangeFormatterSettings<LocalizedNumberRangeFormatter>

java.lang.Object
   ↳ android.icu.number.NumberRangeFormatterSettings<android.icu.number.LocalizedNumberRangeFormatter>
     ↳ android.icu.number.LocalizedNumberRangeFormatter


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

Summary

Public methods

FormattedNumberRange formatRange(int first, int second)

Format the given integers to a string using the settings specified in the NumberRangeFormatter fluent setting chain.

FormattedNumberRange formatRange(Number first, Number second)

Format the given Numbers to a string using the settings specified in the NumberRangeFormatter fluent setting chain.

FormattedNumberRange formatRange(double first, double second)

Format the given doubles to a string using the settings specified in the NumberRangeFormatter fluent setting chain.

UnlocalizedNumberRangeFormatter withoutLocale()

Disassociate the locale from this formatter.

Inherited methods

T collapse(NumberRangeFormatter.RangeCollapse collapse)

Sets the aggressiveness of "collapsing" fields across the range separator.

boolean equals(Object other)

Indicates whether some other object is "equal to" this one.

int hashCode()

Returns a hash code value for the object.

T identityFallback(NumberRangeFormatter.RangeIdentityFallback identityFallback)

Sets the behavior when the two sides of the range are the same.

T numberFormatterBoth(UnlocalizedNumberFormatter formatter)

Sets the NumberFormatter instance to use for the numbers in the range.

T numberFormatterFirst(UnlocalizedNumberFormatter formatterFirst)

Sets the NumberFormatter instance to use for the first number in the range.

T numberFormatterSecond(UnlocalizedNumberFormatter formatterSecond)

Sets the NumberFormatter instances to use for the second number in the range.

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public methods

formatRange

Added in API level 30
public FormattedNumberRange formatRange (int first, 
                int second)

Format the given integers to a string using the settings specified in the NumberRangeFormatter fluent setting chain.

Parameters
first int: The first number in the range, usually to the left in LTR locales.

second int: The second number in the range, usually to the right in LTR locales.

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

formatRange

Added in API level 30
public FormattedNumberRange formatRange (Number first, 
                Number second)

Format the given Numbers to a string using the settings specified in the NumberRangeFormatter fluent setting chain.

Parameters
first Number: The first number in the range, usually to the left in LTR locales.

second Number: The second number in the range, usually to the right in LTR locales.

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

Throws
IllegalArgumentException if first or second is null

formatRange

Added in API level 30
public FormattedNumberRange formatRange (double first, 
                double second)

Format the given doubles to a string using the settings specified in the NumberRangeFormatter fluent setting chain.

Parameters
first double: The first number in the range, usually to the left in LTR locales.

second double: The second number in the range, usually to the right in LTR locales.

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

withoutLocale

public UnlocalizedNumberRangeFormatter withoutLocale ()

Disassociate the locale from this formatter.

Returns
UnlocalizedNumberRangeFormatter The fluent chain.