|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
com.ibm.icu.text.UFormat
com.ibm.icu.text.NumberFormat
com.ibm.icu.text.DecimalFormat
com.ibm.icu.text.CompactDecimalFormat
public class CompactDecimalFormat
The CompactDecimalFormat produces abbreviated numbers, suitable for display in environments will limited real estate. For example, 'Hits: 1.2B' instead of 'Hits: 1,200,000,000'. The format will be appropriate for the given language, such as "1,2 Mrd." for German.
For numbers under 1000 trillion (under 10^15, such as 123,456,789,012,345), the result will be short for supported languages. However, the result may sometimes exceed 7 characters, such as when there are combining marks or thin characters. In such cases, the visual width in fonts should still be short.
By default, there are 2 significant digits. After creation, if more than three significant digits are set (with setMaximumSignificantDigits), or if a fixed number of digits are set (with setMaximumIntegerDigits or setMaximumFractionDigits), then result may be wider.
At this time, negative numbers and parsing are not supported, and will produce an UnsupportedOperationException. Resetting the pattern prefixes or suffixes is not supported; the method calls are ignored.
Note that important methods, like setting the number of decimals, will be moved up from DecimalFormat to NumberFormat.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.ibm.icu.text.NumberFormat |
|---|
NumberFormat.CompactStyle, NumberFormat.Field, NumberFormat.NumberFormatFactory, NumberFormat.SimpleNumberFormatFactory |
| Field Summary |
|---|
| Fields inherited from class com.ibm.icu.text.DecimalFormat |
|---|
PAD_AFTER_PREFIX, PAD_AFTER_SUFFIX, PAD_BEFORE_PREFIX, PAD_BEFORE_SUFFIX |
| Fields inherited from class com.ibm.icu.text.NumberFormat |
|---|
CURRENCYSTYLE, FRACTION_FIELD, INTEGER_FIELD, INTEGERSTYLE, ISOCURRENCYSTYLE, NUMBERSTYLE, PERCENTSTYLE, PLURALCURRENCYSTYLE, SCIENTIFICSTYLE |
| Constructor Summary | |
|---|---|
CompactDecimalFormat(String pattern,
DecimalFormatSymbols formatSymbols,
String[] prefix,
String[] suffix,
long[] divisor,
Collection<String> debugCreationErrors,
NumberFormat.CompactStyle style,
String[] currencyAffixes)
Create a short number "from scratch". |
|
| Method Summary | |
|---|---|
StringBuffer |
format(BigDecimal number,
StringBuffer toAppendTo,
FieldPosition pos)
Formats a BigDecimal number. |
StringBuffer |
format(BigDecimal number,
StringBuffer toAppendTo,
FieldPosition pos)
Formats a BigDecimal number. |
StringBuffer |
format(BigInteger number,
StringBuffer toAppendTo,
FieldPosition pos)
Formats a BigInteger number. |
StringBuffer |
format(double number,
StringBuffer toAppendTo,
FieldPosition pos)
Specialization of format. |
StringBuffer |
format(long number,
StringBuffer toAppendTo,
FieldPosition pos)
Specialization of format. |
Number |
parse(String text,
ParsePosition parsePosition)
Parsing is currently unsupported, and throws an UnsupportedOperationException. |
| Methods inherited from class com.ibm.icu.text.UFormat |
|---|
getLocale |
| Methods inherited from class java.text.Format |
|---|
format, parseObject |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CompactDecimalFormat(String pattern,
DecimalFormatSymbols formatSymbols,
String[] prefix,
String[] suffix,
long[] divisor,
Collection<String> debugCreationErrors,
NumberFormat.CompactStyle style,
String[] currencyAffixes)
pattern - A number format pattern. Note that the prefix and suffix are discarded, and the decimals are
overridden by default.formatSymbols - Decimal format symbols, typically from a locale.prefix - An array of prefix values, one for each power of 10 from 0 to 14suffix - An array of prefix values, one for each power of 10 from 0 to 14divisor - An array of prefix values, one for each power of 10 from 0 to 14debugCreationErrors - A collection of strings for debugging. If null on input, then any errors found will be added to that
collection instead of throwing exceptions.| Method Detail |
|---|
public StringBuffer format(double number,
StringBuffer toAppendTo,
FieldPosition pos)
format in class DecimalFormatFormat.format(Object, StringBuffer, FieldPosition)
public StringBuffer format(long number,
StringBuffer toAppendTo,
FieldPosition pos)
format in class DecimalFormatFormat.format(Object, StringBuffer, FieldPosition)
public StringBuffer format(BigInteger number,
StringBuffer toAppendTo,
FieldPosition pos)
format in class DecimalFormatFormat.format(Object, StringBuffer, FieldPosition)
public StringBuffer format(BigDecimal number,
StringBuffer toAppendTo,
FieldPosition pos)
format in class DecimalFormatFormat.format(Object, StringBuffer, FieldPosition)
public StringBuffer format(BigDecimal number,
StringBuffer toAppendTo,
FieldPosition pos)
format in class DecimalFormatFormat.format(Object, StringBuffer, FieldPosition)
public Number parse(String text,
ParsePosition parsePosition)
parse in class DecimalFormattext - the string to be parsedparsePosition - defines the position where parsing is to begin, and upon
return, the position where parsing left off. If the position has not changed upon
return, then parsing failed.
Number object with the parsed value or
null if the parse failedNumberFormat.isParseIntegerOnly(),
Format.parseObject(String, ParsePosition)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||