# Print output for @column tags ?>
public
abstract
class
NumberFormatterSettings
extends Object
java.lang.Object | |
↳ | android.icu.number.NumberFormatterSettings<T extends android.icu.number.NumberFormatterSettings<?>> |
An abstract base class for specifying settings related to number formatting. This class is implemented
by UnlocalizedNumberFormatter
and LocalizedNumberFormatter
. This class is not intended
for public subclassing.
See also:
Public methods | |
---|---|
T
|
decimal(NumberFormatter.DecimalSeparatorDisplay style)
Sets the decimal separator display strategy. |
boolean
|
equals(Object other)
Indicates whether some other object is "equal to" this one. |
T
|
grouping(NumberFormatter.GroupingStrategy strategy)
Specifies the grouping strategy to use when formatting numbers. |
int
|
hashCode()
Returns a hash code value for the object. |
T
|
integerWidth(IntegerWidth style)
Specifies the minimum and maximum number of digits to render before the decimal mark. |
T
|
notation(Notation notation)
Specifies the notation style (simple, scientific, or compact) for rendering numbers. |
T
|
perUnit(MeasureUnit perUnit)
Sets a unit to be used in the denominator. |
T
|
precision(Precision precision)
Specifies the rounding precision to use when formatting numbers. |
T
|
roundingMode(RoundingMode roundingMode)
Specifies how to determine the direction to round a number when it has more digits than fit in the desired precision. |
T
|
scale(Scale scale)
Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting. |
T
|
sign(NumberFormatter.SignDisplay style)
Sets the plus/minus sign display strategy. |
T
|
symbols(NumberingSystem ns)
Specifies that the given numbering system should be used when fetching symbols. |
T
|
symbols(DecimalFormatSymbols symbols)
Specifies the symbols (decimal separator, grouping separator, percent sign, numerals, etc.) to use when rendering numbers. |
T
|
unit(MeasureUnit unit)
Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers. |
T
|
unitWidth(NumberFormatter.UnitWidth style)
Sets the width of the unit (measure unit or currency). |
Inherited methods | |
---|---|
public T decimal (NumberFormatter.DecimalSeparatorDisplay style)
Sets the decimal separator display strategy. This affects integer numbers with no fraction part. Most common values:
Pass an element from the DecimalSeparatorDisplay
enum to this setter. For example:
NumberFormatter.with().decimal(DecimalSeparatorDisplay.ALWAYS)
The default is AUTO decimal separator display.
Parameters | |
---|---|
style |
NumberFormatter.DecimalSeparatorDisplay : The decimal separator display strategy to use when rendering numbers. |
Returns | |
---|---|
T |
The fluent chain |
See also:
public boolean equals (Object other)
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y)
consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals
method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode
method, which states
that equal objects must have equal hash codes.
Parameters | |
---|---|
other |
Object : the reference object with which to compare. |
Returns | |
---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
public T grouping (NumberFormatter.GroupingStrategy strategy)
Specifies the grouping strategy to use when formatting numbers.
The exact grouping widths will be chosen based on the locale.
Pass this method an element from the GroupingStrategy
enum. For example:
NumberFormatter.with().grouping(GroupingStrategy.MIN2)The default is to perform grouping according to locale data; most locales, but not all locales, enable it by default.
Parameters | |
---|---|
strategy |
NumberFormatter.GroupingStrategy : The grouping strategy to use. |
Returns | |
---|---|
T |
The fluent chain. |
See also:
public int hashCode ()
Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
Returns | |
---|---|
int |
a hash code value for this object. |
public T integerWidth (IntegerWidth style)
Specifies the minimum and maximum number of digits to render before the decimal mark.
Pass this method the return value of IntegerWidth#zeroFillTo(int)
. For example:
NumberFormatter.with().integerWidth(IntegerWidth.zeroFillTo(2))The default is to have one minimum integer digit.
Parameters | |
---|---|
style |
IntegerWidth : The integer width to use. |
Returns | |
---|---|
T |
The fluent chain. |
See also:
public T notation (Notation notation)
Specifies the notation style (simple, scientific, or compact) for rendering numbers.
All notation styles will be properly localized with locale data, and all notation styles are compatible with units, rounding strategies, and other number formatter settings.
Pass this method the return value of a Notation
factory method. For example:
NumberFormatter.with().notation(Notation.compactShort())The default is to use simple notation.
Parameters | |
---|---|
notation |
Notation : The notation strategy to use. |
Returns | |
---|---|
T |
The fluent chain. |
See also:
public T perUnit (MeasureUnit perUnit)
Sets a unit to be used in the denominator. For example, to format "3 m/s", pass METER to the unit and SECOND to the perUnit.
Pass this method any instance of MeasureUnit
. For example:
NumberFormatter.with().unit(MeasureUnit.METER).perUnit(MeasureUnit.SECOND)
The default is not to display any unit in the denominator.
If a per-unit is specified without a primary unit via unit(MeasureUnit)
, the behavior is undefined.
Parameters | |
---|---|
perUnit |
MeasureUnit : The unit to render in the denominator. |
Returns | |
---|---|
T |
The fluent chain |
See also:
public T precision (Precision precision)
Specifies the rounding precision to use when formatting numbers.
Pass this method the return value of one of the factory methods on Precision
. For example:
NumberFormatter.with().precision(Precision.fixedFraction(2))
In most cases, the default rounding precision is to round to 6 fraction places; i.e.,
Precision.maxFraction(6)
. The exceptions are if compact notation is being used, then
the compact notation rounding precision is used (see Notation#compactShort
for details), or
if the unit is a currency, then standard currency rounding is used, which varies from currency to
currency (see Precision#currency
for details).
Parameters | |
---|---|
precision |
Precision : The rounding precision to use. |
Returns | |
---|---|
T |
The fluent chain. |
See also:
public T roundingMode (RoundingMode roundingMode)
Specifies how to determine the direction to round a number when it has more digits than fit in the desired precision. When formatting 1.235:
Parameters | |
---|---|
roundingMode |
RoundingMode : The rounding mode to use. |
Returns | |
---|---|
T |
The fluent chain. |
See also:
public T scale (Scale scale)
Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting. Most common values:
Pass an element from a Scale
factory method to this setter. For example:
NumberFormatter.with().scale(Scale.powerOfTen(2))
The default is to not apply any multiplier.
Parameters | |
---|---|
scale |
Scale : An amount to be multiplied against numbers before formatting. |
Returns | |
---|---|
T |
The fluent chain |
See also:
public T sign (NumberFormatter.SignDisplay style)
Sets the plus/minus sign display strategy. Most common values:
Pass an element from the SignDisplay
enum to this setter. For example:
NumberFormatter.with().sign(SignDisplay.ALWAYS)
The default is AUTO sign display.
Parameters | |
---|---|
style |
NumberFormatter.SignDisplay : The sign display strategy to use when rendering numbers. |
Returns | |
---|---|
T |
The fluent chain |
See also:
public T symbols (NumberingSystem ns)
Specifies that the given numbering system should be used when fetching symbols.
Pass this method an instance of NumberingSystem
. For example, to force the locale to
always use the Latin alphabet numbering system (ASCII digits):
NumberFormatter.with().symbols(NumberingSystem.LATIN)
Note: Calling this method will override the DecimalFormatSymbols previously
specified in symbols(android.icu.text.DecimalFormatSymbols)
.
The default is to choose the best numbering system for the locale.
Parameters | |
---|---|
ns |
NumberingSystem : The NumberingSystem to use. |
Returns | |
---|---|
T |
The fluent chain. |
See also:
public T symbols (DecimalFormatSymbols symbols)
Specifies the symbols (decimal separator, grouping separator, percent sign, numerals, etc.) to use when rendering numbers.
Pass this method an instance of DecimalFormatSymbols
. For example:
NumberFormatter.with().symbols(DecimalFormatSymbols.getInstance(new ULocale("de_CH")))
Note: DecimalFormatSymbols automatically chooses the best numbering system based on the locale. In the examples above, the first three are using the Latin numbering system, and the fourth is using the Myanmar numbering system.
Note: The instance of DecimalFormatSymbols will be copied: changes made to the symbols object after passing it into the fluent chain will not be seen.
Note: Calling this method will override the NumberingSystem previously specified
in symbols(android.icu.text.NumberingSystem)
.
The default is to choose the symbols based on the locale specified in the fluent chain.
Parameters | |
---|---|
symbols |
DecimalFormatSymbols : The DecimalFormatSymbols to use. |
Returns | |
---|---|
T |
The fluent chain. |
See also:
public T unit (MeasureUnit unit)
Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers.
Note: The unit can also be specified by passing a Measure
to
LocalizedNumberFormatter#format(Measure)
. Units specified via the format method take
precedence over units specified here. This setter is designed for situations when the unit is
constant for the duration of the number formatting process.
All units will be properly localized with locale data, and all units are compatible with notation styles, rounding strategies, and other number formatter settings.
Pass this method any instance of MeasureUnit
. For units of measure:
NumberFormatter.with().unit(MeasureUnit.METER)Currency:
NumberFormatter.with().unit(Currency.getInstance("USD"))
See perUnit(MeasureUnit)
for information on how to format strings like "5 meters per second".
If the input usage is correctly set the output unit will change according to `usage`, `locale` and `unit` value.
Parameters | |
---|---|
unit |
MeasureUnit : The unit to render. |
Returns | |
---|---|
T |
The fluent chain. |
See also:
public T unitWidth (NumberFormatter.UnitWidth style)
Sets the width of the unit (measure unit or currency). Most common values:
Pass an element from the UnitWidth
enum to this setter. For example:
NumberFormatter.with().unitWidth(UnitWidth.FULL_NAME)
The default is the SHORT width.
Parameters | |
---|---|
style |
NumberFormatter.UnitWidth : The width to use when rendering numbers. |
Returns | |
---|---|
T |
The fluent chain |
See also: