FormattedRelativeDateTime
class FormattedRelativeDateTime : FormattedValue
kotlin.Any | |
↳ | android.icu.text.RelativeDateTimeFormatter.FormattedRelativeDateTime |
Represents the result of a formatting operation of a relative datetime. Access the string value or field information. Instances of this class are immutable and thread-safe. Not intended for public subclassing.
Summary
Public methods | |
---|---|
open A |
appendTo(appendable: A) Appends the formatted string to an Appendable. |
open Char |
Returns the |
open Boolean |
nextPosition(cfpos: ConstrainedFieldPosition!) Iterates over field positions in the FormattedValue. |
open CharSequence |
subSequence(startIndex: Int, endIndex: Int) Returns a |
open AttributedCharacterIterator! |
Exports the formatted number as an AttributedCharacterIterator. |
open String |
toString() Returns a string representation of the object. |
Properties | |
---|---|
open Int |
Returns the length of this character sequence. |
Public methods
appendTo
open 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
open 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
open 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
open 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 char
s) 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
open 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
open fun toString(): String
Returns a string representation of the object.
Return | |
---|---|
String |
The formatted string. |
Properties
length
open val length: Int
Returns the length of this character sequence. The length is the number of 16-bit char
s in the sequence.
Return | |
---|---|
Int |
the number of char s in this sequence |