Language

RelativeDateTimeFormatter.Format Method

Definition

Overloads

Name Description
Format(RelativeDateTimeFormatter+Direction, RelativeDateTimeFormatter+AbsoluteUnit)

Formats a relative date without a quantity.

Format(Double, RelativeDateTimeFormatter+RelativeDateTimeUnit)

Format a combination of RelativeDateTimeUnit and numeric offset using a text style if possible, e.g. "last week", "this week", "next week", "yesterday", "tomorrow".

Format(Double, RelativeDateTimeFormatter+Direction, RelativeDateTimeFormatter+RelativeUnit)

Formats a relative date with a quantity such as "in 5 days" or "3 months ago".

Format(RelativeDateTimeFormatter+Direction, RelativeDateTimeFormatter+AbsoluteUnit)

Formats a relative date without a quantity.

[Android.Runtime.Register("format", "(Landroid/icu/text/RelativeDateTimeFormatter$Direction;Landroid/icu/text/RelativeDateTimeFormatter$AbsoluteUnit;)Ljava/lang/String;", "", ApiSince=24)]
public string? Format(Android.Icu.Text.RelativeDateTimeFormatter.Direction? direction, Android.Icu.Text.RelativeDateTimeFormatter.AbsoluteUnit? unit);
[<Android.Runtime.Register("format", "(Landroid/icu/text/RelativeDateTimeFormatter$Direction;Landroid/icu/text/RelativeDateTimeFormatter$AbsoluteUnit;)Ljava/lang/String;", "", ApiSince=24)>]
member this.Format : Android.Icu.Text.RelativeDateTimeFormatter.Direction * Android.Icu.Text.RelativeDateTimeFormatter.AbsoluteUnit -> string

Parameters

direction
RelativeDateTimeFormatter.Direction

NEXT, LAST, THIS, etc.

unit
RelativeDateTimeFormatter.AbsoluteUnit

e.g SATURDAY, DAY, MONTH

Returns

the formatted string. If direction has a value that is documented as not being fully supported in every locale (for example NEXT_2 or LAST_2) then this function may return null to signal that no formatted string is available.

Attributes

Remarks

Formats a relative date without a quantity. This method returns a String. To get more information about the formatting result, use formatToValue().

Android reference for android.icu.text.RelativeDateTimeFormatter.format.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Format(Double, RelativeDateTimeFormatter+RelativeDateTimeUnit)

Format a combination of RelativeDateTimeUnit and numeric offset using a text style if possible, e.g. "last week", "this week", "next week", "yesterday", "tomorrow".

[Android.Runtime.Register("format", "(DLandroid/icu/text/RelativeDateTimeFormatter$RelativeDateTimeUnit;)Ljava/lang/String;", "", ApiSince=28)]
public string? Format(double offset, Android.Icu.Text.RelativeDateTimeFormatter.RelativeDateTimeUnit? unit);
[<Android.Runtime.Register("format", "(DLandroid/icu/text/RelativeDateTimeFormatter$RelativeDateTimeUnit;)Ljava/lang/String;", "", ApiSince=28)>]
member this.Format : double * Android.Icu.Text.RelativeDateTimeFormatter.RelativeDateTimeUnit -> string

Parameters

offset
Double

The signed offset for the specified field.

unit
RelativeDateTimeFormatter.RelativeDateTimeUnit

The unit to use when formatting the relative date, e.g. RelativeDateTimeUnit.WEEK, RelativeDateTimeUnit.FRIDAY.

Returns

The formatted string (may be empty in case of error)

Attributes

Remarks

Format a combination of RelativeDateTimeUnit and numeric offset using a text style if possible, e.g. "last week", "this week", "next week", "yesterday", "tomorrow". Falls back to numeric style if no appropriate text term is available for the specified offset in the object’s locale. This method returns a String. To get more information about the formatting result, use formatToValue().

Android reference for android.icu.text.RelativeDateTimeFormatter.format.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Format(Double, RelativeDateTimeFormatter+Direction, RelativeDateTimeFormatter+RelativeUnit)

Formats a relative date with a quantity such as "in 5 days" or "3 months ago".

[Android.Runtime.Register("format", "(DLandroid/icu/text/RelativeDateTimeFormatter$Direction;Landroid/icu/text/RelativeDateTimeFormatter$RelativeUnit;)Ljava/lang/String;", "", ApiSince=24)]
public string? Format(double quantity, Android.Icu.Text.RelativeDateTimeFormatter.Direction? direction, Android.Icu.Text.RelativeDateTimeFormatter.RelativeUnit? unit);
[<Android.Runtime.Register("format", "(DLandroid/icu/text/RelativeDateTimeFormatter$Direction;Landroid/icu/text/RelativeDateTimeFormatter$RelativeUnit;)Ljava/lang/String;", "", ApiSince=24)>]
member this.Format : double * Android.Icu.Text.RelativeDateTimeFormatter.Direction * Android.Icu.Text.RelativeDateTimeFormatter.RelativeUnit -> string

Parameters

quantity
Double

The numerical amount e.g 5. This value is formatted according to this object's NumberFormat object.

direction
RelativeDateTimeFormatter.Direction

NEXT means a future relative date; LAST means a past relative date.

unit
RelativeDateTimeFormatter.RelativeUnit

the unit e.g day? month? year?

Returns

the formatted string

Attributes

Remarks

Formats a relative date with a quantity such as "in 5 days" or "3 months ago". This method returns a String. To get more information about the formatting result, use formatToValue().

Android reference for android.icu.text.RelativeDateTimeFormatter.format.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to