Added in API level 31

FormattedValue


interface FormattedValue : CharSequence
android.icu.text.FormattedValue

An abstract formatted value: a string with associated field attributes. Many formatters format to classes implementing FormattedValue.

Summary

Public methods
abstract A
appendTo(appendable: A)

Appends the formatted string to an Appendable.

abstract Boolean

Iterates over field positions in the FormattedValue.

abstract AttributedCharacterIterator!

Exports the formatted number as an AttributedCharacterIterator.

Public methods

appendTo

Added in API level 31
abstract fun <A : Appendable!> appendTo(appendable: A): A

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.
Return
A The same Appendable, for chaining.
Exceptions
android.icu.util.ICUUncheckedIOException if the Appendable throws IOException

nextPosition

Added in API level 31
abstract fun nextPosition(cfpos: ConstrainedFieldPosition!): Boolean

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.
Return
Boolean true if a new occurrence of the field was found; false otherwise.

toCharacterIterator

Added in API level 31
abstract fun toCharacterIterator(): AttributedCharacterIterator!

Exports the formatted number as an AttributedCharacterIterator.

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

Return
AttributedCharacterIterator! An AttributedCharacterIterator containing full field information.