Package com.ibm.icu.number
Enum NumberFormatter.UnitWidth
- java.lang.Object
-
- java.lang.Enum<NumberFormatter.UnitWidth>
-
- com.ibm.icu.number.NumberFormatter.UnitWidth
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<NumberFormatter.UnitWidth>
- Enclosing class:
- NumberFormatter
public static enum NumberFormatter.UnitWidth extends java.lang.Enum<NumberFormatter.UnitWidth>
An enum declaring how to render units, including currencies. Example outputs when formatting 123 USD and 123 meters in en-CA:- NARROW: "$123.00" and "123 m"
- SHORT: "US$ 123.00" and "123 m"
- FULL_NAME: "123.00 US dollars" and "123 meters"
- ISO_CODE: "USD 123.00" and undefined behavior
- HIDDEN: "123.00" and "123"
This enum is similar to
MeasureFormat.FormatWidth
.- See Also:
NumberFormatter
-
-
Enum Constant Summary
Enum Constants Enum Constant Description FULL_NAME
Print the full name of the unit, without any abbreviations.HIDDEN
Format the number according to the specified unit, but do not display the unit.ISO_CODE
Use the three-digit ISO XXX code in place of the symbol for displaying currencies.NARROW
Print an abbreviated version of the unit name.SHORT
Print an abbreviated version of the unit name.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NumberFormatter.UnitWidth
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static NumberFormatter.UnitWidth[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NARROW
public static final NumberFormatter.UnitWidth NARROW
Print an abbreviated version of the unit name. Similar to SHORT, but always use the shortest available abbreviation or symbol. This option can be used when the context hints at the identity of the unit. For more information on the difference between NARROW and SHORT, see SHORT.In CLDR, this option corresponds to the "Narrow" format for measure units and the "¤¤¤¤¤" placeholder for currencies.
- See Also:
NumberFormatter
-
SHORT
public static final NumberFormatter.UnitWidth SHORT
Print an abbreviated version of the unit name. Similar to NARROW, but use a slightly wider abbreviation or symbol when there may be ambiguity. This is the default behavior.For example, in es-US, the SHORT form for Fahrenheit is "{0} °F", but the NARROW form is "{0}°", since Fahrenheit is the customary unit for temperature in that locale.
In CLDR, this option corresponds to the "Short" format for measure units and the "¤" placeholder for currencies.
- See Also:
NumberFormatter
-
FULL_NAME
public static final NumberFormatter.UnitWidth FULL_NAME
Print the full name of the unit, without any abbreviations.In CLDR, this option corresponds to the default format for measure units and the "¤¤¤" placeholder for currencies.
- See Also:
NumberFormatter
-
ISO_CODE
public static final NumberFormatter.UnitWidth ISO_CODE
Use the three-digit ISO XXX code in place of the symbol for displaying currencies. The behavior of this option is currently undefined for use with measure units.In CLDR, this option corresponds to the "¤¤" placeholder for currencies.
- See Also:
NumberFormatter
-
HIDDEN
public static final NumberFormatter.UnitWidth HIDDEN
Format the number according to the specified unit, but do not display the unit. For currencies, apply monetary symbols and formats as with SHORT, but omit the currency symbol. For measure units, the behavior is equivalent to not specifying the unit at all.- See Also:
NumberFormatter
-
-
Method Detail
-
values
public static NumberFormatter.UnitWidth[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (NumberFormatter.UnitWidth c : NumberFormatter.UnitWidth.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static NumberFormatter.UnitWidth valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
-