Top Description Fields Constructors Methods
com.ibm.icu.number

public Class IntegerWidth

extends Object
Class Inheritance
Imports
com.ibm.icu.impl.number.RoundingUtils

A class that defines the strategy for padding and truncating integers before the decimal separator.

To create an IntegerWidth, use one of the factory methods.

ICU Status
Stable since ICU 60.
See Also
NumberFormatter

Field Summary

Modifier and TypeField and Description
pack-priv static final IntegerWidth
pack-priv final int
pack-priv final int

Constructor Summary

AccessConstructor and Description
private
IntegerWidth(int minInt, int maxInt)

Method Summary

Modifier and TypeMethod and Description
public IntegerWidth

Returns:

An IntegerWidth for passing to the NumberFormatter integerWidth() setter.
truncateAt
(int
The maximum number of places before the decimal separator. maxInt == -1 means no truncation.
maxInt
)

Truncate numbers exceeding a certain number of numerals before the decimal separator.

public static IntegerWidth

Returns:

An IntegerWidth for chaining or passing to the NumberFormatter integerWidth() setter.
zeroFillTo
(int
The minimum number of places before the decimal separator.
minInt
)

Pad numbers at the beginning with zeros to guarantee a certain number of numerals before the decimal separator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULTback to summary
pack-priv static final IntegerWidth DEFAULT
maxIntback to summary
pack-priv final int maxInt
minIntback to summary
pack-priv final int minInt

Constructor Detail

IntegerWidthback to summary
private IntegerWidth(int minInt, int maxInt)

Method Detail

truncateAtback to summary
public IntegerWidth truncateAt(int maxInt)

Truncate numbers exceeding a certain number of numerals before the decimal separator. For example, with maxInt=3, the number 1234 will get printed as "234".

Parameters
maxInt:int

The maximum number of places before the decimal separator. maxInt == -1 means no truncation.

Returns:IntegerWidth

An IntegerWidth for passing to the NumberFormatter integerWidth() setter.

Exceptions
IllegalArgumentException:
if the input number is too big or smaller than -1.
ICU Status
Stable since ICU 60.
See Also
NumberFormatter
zeroFillToback to summary
public static IntegerWidth zeroFillTo(int minInt)

Pad numbers at the beginning with zeros to guarantee a certain number of numerals before the decimal separator.

For example, with minInt=3, the number 55 will get printed as "055".

Parameters
minInt:int

The minimum number of places before the decimal separator.

Returns:IntegerWidth

An IntegerWidth for chaining or passing to the NumberFormatter integerWidth() setter.

Exceptions
IllegalArgumentException:
if the input number is too big or smaller than 0.
ICU Status
Stable since ICU 60.
See Also
NumberFormatter