Top Description Methods
com.ibm.icu.text

public Interface FormattedValue

extends CharSequence
Known Direct Implementers
com.ibm.icu.text.ListFormatter.FormattedList, com.ibm.icu.text.DateIntervalFormat.FormattedDateInterval, com.ibm.icu.message2.FormattedMessage, com.ibm.icu.message2.PlainStringFormattedValue, com.ibm.icu.number.FormattedNumber, com.ibm.icu.number.FormattedNumberRange, com.ibm.icu.text.RelativeDateTimeFormatter.FormattedRelativeDateTime
Imports
java.text.AttributedCharacterIterator, com.ibm.icu.util.ICUUncheckedIOException

An abstract formatted value: a string with associated field attributes. Many formatters format to classes implementing FormattedValue.
Author
sffc
ICU Status
Stable since ICU 64.

Method Summary

Modifier and TypeMethod and Description
public <A extends Appendable> A

Returns:

The same Appendable, for chaining.
appendTo
(A
The Appendable to which to append the string output.
appendable
)

Appends the formatted string to an Appendable.

public boolean

Returns:

true if a new occurrence of the field was found; false otherwise.
nextPosition
(ConstrainedFieldPosition
The object used for iteration state. This can provide constraints to iterate over only one specific field; see ConstrainedFieldPosition#constrainField.
cfpos
)

Iterates over field positions in the FormattedValue.

public AttributedCharacterIterator

Returns:

An AttributedCharacterIterator containing full field information.
toCharacterIterator
()

Exports the formatted number as an AttributedCharacterIterator.

public String

Returns:

The formatted string.
toString
()

Redeclares java.lang.CharSequence.toString.

Returns the formatted string as a Java String.
Inherited from java.lang.CharSequence:
charAtcharscodePointscompareisEmptylengthsubSequence

Method Detail

appendToback to summary
public <A extends Appendable> A appendTo(A appendable)

Appends the formatted string to an Appendable.

If an IOException occurs when appending to the Appendable, an unchecked ICUUncheckedIOException is thrown instead.

Parameters
appendable:A

The Appendable to which to append the string output.

Returns:A

The same Appendable, for chaining.

Exceptions
ICUUncheckedIOException:
if the Appendable throws IOException
ICU Status
Stable since ICU 64.
nextPositionback to summary
public boolean nextPosition(ConstrainedFieldPosition cfpos)

Iterates over field positions in the FormattedValue. This lets you determine the position of specific types of substrings, like a month or a decimal separator. To loop over all field positions:

    ConstrainedFieldPosition cfpos = new ConstrainedFieldPosition();
    while (fmtval.nextPosition(cfpos)) {
        // handle the field position; get information from cfpos
    }
Parameters
cfpos:ConstrainedFieldPosition

The object used for iteration state. This can provide constraints to iterate over only one specific field; see ConstrainedFieldPosition#constrainField.

Returns:boolean

true if a new occurrence of the field was found; false otherwise.

ICU Status
Stable since ICU 64.
toCharacterIteratorback to summary
public AttributedCharacterIterator toCharacterIterator()

Exports the formatted number as an AttributedCharacterIterator.

Consider using nextPosition if you are trying to get field information.

Returns:AttributedCharacterIterator

An AttributedCharacterIterator containing full field information.

ICU Status
Stable since ICU 64.
toStringback to summary
public String toString()

Redeclares java.lang.CharSequence.toString.

Returns the formatted string as a Java String. Consider using appendTo for greater efficiency.

Returns:String

The formatted string.

Annotations
@Override
ICU Status
Stable since ICU 64.