DateUtils.GetRelativeTimeSpanString Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetRelativeTimeSpanString(Int64, Int64, Int64, FormatStyleFlags) |
Returns a string describing 'time' as a time relative to 'now'. |
GetRelativeTimeSpanString(Context, Int64, Boolean) |
Returns a string describing the elapsed time since startTime. |
GetRelativeTimeSpanString(Int64, Int64, Int64) |
Returns a string describing 'time' as a time relative to 'now'. |
GetRelativeTimeSpanString(Int64) |
Returns a string describing the elapsed time since startTime. |
GetRelativeTimeSpanString(Context, Int64) |
Convenience function to return relative time string without preposition. |
GetRelativeTimeSpanString(Int64, Int64, Int64, FormatStyleFlags)
Returns a string describing 'time' as a time relative to 'now'.
public static string? GetRelativeTimeSpanString (long time, long now, long minResolution, Android.Text.Format.FormatStyleFlags flags);
static member GetRelativeTimeSpanString : int64 * int64 * int64 * Android.Text.Format.FormatStyleFlags -> string
Parameters
- time
- Int64
the time to describe, in milliseconds
- now
- Int64
the current time in milliseconds
- minResolution
- Int64
the minimum timespan to report. For example, a time 3 seconds in the past will be reported as "0 minutes ago" if this is set to MINUTE_IN_MILLIS. Pass one of 0, MINUTE_IN_MILLIS, HOUR_IN_MILLIS, DAY_IN_MILLIS, WEEK_IN_MILLIS
- flags
- FormatStyleFlags
a bit mask of formatting options, such as
#FORMAT_NUMERIC_DATE
or
#FORMAT_ABBREV_RELATIVE
Returns
a String object containing the elapsed time.
Remarks
Returns a string describing 'time' as a time relative to 'now'.
Time spans in the past are formatted like "42 minutes ago". Time spans in the future are formatted like "In 42 minutes".
Can use #FORMAT_ABBREV_RELATIVE
flag to use abbreviated relative times, like "42 mins ago".
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
GetRelativeTimeSpanString(Context, Int64, Boolean)
Returns a string describing the elapsed time since startTime.
public static string? GetRelativeTimeSpanString (Android.Content.Context? c, long millis, bool withPreposition);
static member GetRelativeTimeSpanString : Android.Content.Context * int64 * bool -> string
Parameters
- c
- Context
- millis
- Int64
- withPreposition
- Boolean
If true, the string returned will include the correct preposition ("at 9:20am", "on 10/12/2008" or "on May 29").
Returns
a relative time string to display the time expressed by millis. Times are counted starting at midnight, which means that assuming that the current time is March 31st, 0:30: <ul> <li>"millis=0:10 today" will be displayed as "0:10"</li> <li>"millis=11:30pm the day before" will be displayed as "Mar 30"</li> </ul> If the given millis is in a different year, then the full date is returned in numeric format (e.g., "10/12/2008").
Remarks
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
GetRelativeTimeSpanString(Int64, Int64, Int64)
Returns a string describing 'time' as a time relative to 'now'.
public static string? GetRelativeTimeSpanString (long time, long now, long minResolution);
static member GetRelativeTimeSpanString : int64 * int64 * int64 -> string
Parameters
- time
- Int64
the time to describe, in milliseconds
- now
- Int64
the current time in milliseconds
- minResolution
- Int64
the minimum timespan to report. For example, a time 3 seconds in the past will be reported as "0 minutes ago" if this is set to MINUTE_IN_MILLIS. Pass one of 0, MINUTE_IN_MILLIS, HOUR_IN_MILLIS, DAY_IN_MILLIS, WEEK_IN_MILLIS
Returns
a String object containing the elapsed time.
Remarks
Returns a string describing 'time' as a time relative to 'now'.
Time spans in the past are formatted like "42 minutes ago". Time spans in the future are formatted like "In 42 minutes".
Java documentation for android.text.format.DateUtils.getRelativeTimeSpanString(long, long, long)
.
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
GetRelativeTimeSpanString(Int64)
Returns a string describing the elapsed time since startTime.
public static string? GetRelativeTimeSpanString (long startTime);
static member GetRelativeTimeSpanString : int64 -> string
Parameters
- startTime
- Int64
some time in the past.
Returns
a String object containing the elapsed time.
Remarks
Returns a string describing the elapsed time since startTime.
The minimum timespan to report is set to #MINUTE_IN_MILLIS
.
Java documentation for android.text.format.DateUtils.getRelativeTimeSpanString(long)
.
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
GetRelativeTimeSpanString(Context, Int64)
Convenience function to return relative time string without preposition.
public static string? GetRelativeTimeSpanString (Android.Content.Context? c, long millis);
static member GetRelativeTimeSpanString : Android.Content.Context * int64 -> string
Parameters
- c
- Context
context for resources
- millis
- Int64
time in milliseconds
Returns
CharSequence
containing relative time.
Remarks
Convenience function to return relative time string without preposition.
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.