Added in API level 31

FormattedDateInterval


class FormattedDateInterval : FormattedValue
kotlin.Any
   ↳ android.icu.text.DateIntervalFormat.FormattedDateInterval

An immutable class containing the result of a date interval formatting operation. Instances of this class are immutable and thread-safe. Not intended for public subclassing.

Summary

Public methods
A
appendTo(appendable: A)

Appends the formatted string to an Appendable.

Char
get(index: Int)

Returns the char value at the specified index.

Boolean

Iterates over field positions in the FormattedValue.

CharSequence
subSequence(startIndex: Int, endIndex: Int)

Returns a CharSequence that is a subsequence of this sequence.

AttributedCharacterIterator!

Exports the formatted number as an AttributedCharacterIterator.

String

Returns a string representation of the object.

Properties
Int

Returns the length of this character sequence.

Public methods

appendTo

Added in API level 31
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

get

Added in API level 31
fun get(index: Int): Char

Returns the char value at the specified index. An index ranges from zero to length() - 1. The first char value of the sequence is at index zero, the next at index one, and so on, as for array indexing.

If the char value specified by the index is a surrogate, the surrogate value is returned.

Parameters
index Int: the index of the char value to be returned
Return
Char the specified char value
Exceptions
java.lang.IndexOutOfBoundsException if the index argument is negative or not less than length()

nextPosition

Added in API level 31
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.

subSequence

Added in API level 31
fun subSequence(
    startIndex: Int,
    endIndex: Int
): CharSequence

Returns a CharSequence that is a subsequence of this sequence. The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.

Parameters
start the start index, inclusive
end the end index, exclusive
Return
CharSequence the specified subsequence
Exceptions
java.lang.IndexOutOfBoundsException if start or end are negative, if end is greater than length(), or if start is greater than end

toCharacterIterator

Added in API level 31
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.

toString

Added in API level 31
fun toString(): String

Returns a string representation of the object.

Return
String The formatted string.

Properties

length

Added in API level 31
val length: Int

Returns the length of this character sequence. The length is the number of 16-bit chars in the sequence.

Return
Int the number of chars in this sequence