DateUtils.GetRelativeTimeSpanString 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| GetRelativeTimeSpanString(Int64, Int64, Int64, FormatStyleFlags) |
回傳一個描述「時間」相對於「現在」的時間的字串。 |
| GetRelativeTimeSpanString(Context, Int64, Boolean) |
回傳一個描述自 startTime 以來經過時間的字串。 |
| GetRelativeTimeSpanString(Int64, Int64, Int64) |
回傳一個描述「時間」相對於「現在」的時間的字串。 |
| GetRelativeTimeSpanString(Int64) |
回傳一個描述自 startTime 以來經過時間的字串。 |
| GetRelativeTimeSpanString(Context, Int64) |
方便函數可回傳無介詞的相對時間串。 |
GetRelativeTimeSpanString(Int64, Int64, Int64, FormatStyleFlags)
回傳一個描述「時間」相對於「現在」的時間的字串。
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
參數
- time
- Int64
描述的時間,以毫秒計
- now
- Int64
目前時間(毫秒)
- minResolution
- Int64
最低報告時間。 例如,若將時間設定為 MINUTE_IN_MILLIS,則將顯示為「0 分鐘前」。 傳一個,0、MINUTE_IN_MILLIS、HOUR_IN_MILLIS、DAY_IN_MILLIS、WEEK_IN_MILLIS
- flags
- FormatStyleFlags
一個格式選項的遮罩,例如#FORMAT_NUMERIC_DATE#FORMAT_ABBREV_RELATIVE
傳回
一個包含經過時間的 String 物件。
備註
回傳一個描述「時間」相對於「現在」的時間的字串。
過去的時間跨度格式是「42 分鐘前」。 未來的時間跨度格式為「42分鐘後」。
可以用 #FORMAT_ABBREV_RELATIVE flag 來表示縮寫的相對時間,比如「42 分鐘前」。
Java 文件 android.text.format.DateUtils.getRelativeTimeSpanString(long, long, long, int)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。
適用於
GetRelativeTimeSpanString(Context, Int64, Boolean)
回傳一個描述自 startTime 以來經過時間的字串。
public static string? GetRelativeTimeSpanString(Android.Content.Context? c, long millis, bool withPreposition);
static member GetRelativeTimeSpanString : Android.Content.Context * int64 * bool -> string
參數
- c
- Context
- millis
- Int64
- withPreposition
- Boolean
若為真,回傳的字串將包含正確的介系詞(「at 9:20am」、「on 10/12/2008」或「on May 29」)。
傳回
一個相對時間串,用來顯示以毫數表示的時間。 時間從午夜開始計算,意即假設當前時間為3月31日0:30:<><ul li>“millis=0:10 today”會顯示為“0:10”</li><li>“millis=11:30 the day will will 顯示為”Mar 30“</li></ul>。若該密利年份不同,則完整日期以數字格式回傳(例如, "10/12/2008").
備註
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。
適用於
GetRelativeTimeSpanString(Int64, Int64, Int64)
回傳一個描述「時間」相對於「現在」的時間的字串。
public static string? GetRelativeTimeSpanString(long time, long now, long minResolution);
static member GetRelativeTimeSpanString : int64 * int64 * int64 -> string
參數
- time
- Int64
描述的時間,以毫秒計
- now
- Int64
目前時間(毫秒)
- minResolution
- Int64
最低報告時間。 例如,若將時間設定為 MINUTE_IN_MILLIS,則將顯示為「0 分鐘前」。 傳一個,0、MINUTE_IN_MILLIS、HOUR_IN_MILLIS、DAY_IN_MILLIS、WEEK_IN_MILLIS
傳回
一個包含經過時間的 String 物件。
備註
回傳一個描述「時間」相對於「現在」的時間的字串。
過去的時間跨度格式是「42 分鐘前」。 未來的時間跨度格式為「42分鐘後」。
Java 文件 android.text.format.DateUtils.getRelativeTimeSpanString(long, long, long)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。
適用於
GetRelativeTimeSpanString(Int64)
回傳一個描述自 startTime 以來經過時間的字串。
public static string? GetRelativeTimeSpanString(long startTime);
static member GetRelativeTimeSpanString : int64 -> string
參數
- startTime
- Int64
是過去某個時候。
傳回
一個包含經過時間的 String 物件。
備註
回傳一個描述自 startTime 以來經過時間的字串。
報告的最小時間區間設為 #MINUTE_IN_MILLIS。
Java 文件 android.text.format.DateUtils.getRelativeTimeSpanString(long)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。
適用於
GetRelativeTimeSpanString(Context, Int64)
方便函數可回傳無介詞的相對時間串。
public static string? GetRelativeTimeSpanString(Android.Content.Context? c, long millis);
static member GetRelativeTimeSpanString : Android.Content.Context * int64 -> string
參數
- c
- Context
資源背景
- millis
- Int64
時間以毫秒計
傳回
CharSequence 包含相對時間。
備註
方便函數可回傳無介詞的相對時間串。
Java 文件 android.text.format.DateUtils.getRelativeTimeSpanString(android.content.Context, long)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。