Partager via


DateUtils.GetRelativeDateTimeString Method

Definition

Return string describing the elapsed time since startTime formatted like "[relative time/date], [time]".

public static string? GetRelativeDateTimeString (Android.Content.Context? c, long time, long minResolution, long transitionResolution, Android.Text.Format.FormatStyleFlags flags);
static member GetRelativeDateTimeString : Android.Content.Context * int64 * int64 * int64 * Android.Text.Format.FormatStyleFlags -> string

Parameters

time
Int64

some time in the past.

minResolution
Int64

the minimum elapsed time (in milliseconds) to report when showing relative times. For example, a time 3 seconds in the past will be reported as "0 minutes ago" if this is set to #MINUTE_IN_MILLIS.

transitionResolution
Int64

the elapsed time (in milliseconds) at which to stop reporting relative measurements. Elapsed times greater than this resolution will default to normal date formatting. For example, will transition from "7 days ago" to "Dec 12" when using #WEEK_IN_MILLIS.

Returns

Remarks

Return string describing the elapsed time since startTime formatted like "[relative time/date], [time]".

Example output strings for the US date format. <ul> <li>3 min. ago, 10:15 AM</li> <li>Yesterday, 12:20 PM</li> <li>Dec 12, 4:12 AM</li> <li>11/14/2007, 8:20 AM</li> </ul>

Java documentation for android.text.format.DateUtils.getRelativeDateTimeString(android.content.Context, long, long, long, int).

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