public class FormattedNumber extends Object implements FormattedValue
NumberFormatter| Modifier and Type | Method and Description |
|---|---|
<A extends Appendable> |
appendTo(A appendable)
Appends the formatted string to an Appendable.
|
char |
charAt(int index) |
boolean |
equals(Object other) |
PluralRules.IFixedDecimal |
getFixedDecimal()
Deprecated.
This API is ICU internal only.
|
int |
hashCode() |
int |
length() |
boolean |
nextFieldPosition(FieldPosition fieldPosition)
Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the
given field in the output string.
|
boolean |
nextPosition(ConstrainedFieldPosition cfpos)
Iterates over field positions in the FormattedValue.
|
CharSequence |
subSequence(int start,
int end) |
BigDecimal |
toBigDecimal()
Export the formatted number as a BigDecimal.
|
AttributedCharacterIterator |
toCharacterIterator()
Exports the formatted number as an AttributedCharacterIterator.
|
String |
toString()
Returns the formatted string as a Java String.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitchars, codePointspublic String toString()
FormattedValue.appendTo(A) for greater efficiency.toString in interface FormattedValuetoString in interface CharSequencetoString in class Objectpublic int length()
length in interface CharSequencepublic char charAt(int index)
charAt in interface CharSequencepublic CharSequence subSequence(int start, int end)
subSequence in interface CharSequencepublic <A extends Appendable> A appendTo(A appendable)
If an IOException occurs when appending to the Appendable, an unchecked
ICUUncheckedIOException is thrown instead.
appendTo in interface FormattedValueappendable - The Appendable to which to append the string output.public boolean nextPosition(ConstrainedFieldPosition cfpos)
ConstrainableFieldPosition cfpos = new ConstrainableFieldPosition();
while (fmtval.nextPosition(cfpos)) {
// handle the field position; get information from cfpos
}
nextPosition in interface FormattedValuecfpos - The object used for iteration state. This can provide constraints to iterate over
only one specific field; see ConstrainedFieldPosition.constrainField(java.text.Format.Field).public AttributedCharacterIterator toCharacterIterator()
Consider using FormattedValue.nextPosition(com.ibm.icu.text.ConstrainedFieldPosition) if you are trying to get field information.
toCharacterIterator in interface FormattedValuepublic boolean nextFieldPosition(FieldPosition fieldPosition)
This is a simpler but less powerful alternative to nextPosition(com.ibm.icu.text.ConstrainedFieldPosition).
If a field occurs just once, calling this method will find that occurrence and return it. If a field occurs multiple times, this method may be called repeatedly with the following pattern:
FieldPosition fpos = new FieldPosition(NumberFormat.Field.GROUPING_SEPARATOR);
while (formattedNumber.nextFieldPosition(fpos, status)) {
// do something with fpos.
}
This method is useful if you know which field to query. If you want all available field position
information, use nextPosition(com.ibm.icu.text.ConstrainedFieldPosition) or toCharacterIterator().
fieldPosition - Input+output variable. On input, the "field" property determines which field to look
up, and the "beginIndex" and "endIndex" properties determine where to begin the search.
On output, the "beginIndex" is set to the beginning of the first occurrence of the
field with either begin or end indices after the input indices, "endIndex" is set to
the end of that occurrence of the field (exclusive index). If a field position is not
found, the method returns FALSE and the FieldPosition may or may not be changed.NumberFormat.Field,
NumberFormatterpublic BigDecimal toBigDecimal()
NumberFormatter@Deprecated public PluralRules.IFixedDecimal getFixedDecimal()
Copyright © 2016 Unicode, Inc. and others.