本文介绍了安卓:getRelativeTime例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人能告诉我一个例子,如何正确使用getRelativetime(),它详细here
Can someone show me an example how to properly use the getRelativetime() that is detailed here
推荐答案
我猜你是在谈论 getRelativeDateTimeString
,这是由你的链接指向的。
I guess you are talking about getRelativeDateTimeString
, which is pointed to by your link.
实例现在
,带注释详细说明所有PARAMS:
Example for now
, with comments detailing all params:
Date now = new Date();
String str = DateUtils.getRelativeDateTimeString(
this, // Suppose you are in an activity or other Context subclass
now.getTime(), // The time to display
DateTimeUtils.MINUTE_IN_MILLIS, // The resolution. This will display only
// minutes (no "3 seconds ago")
DateTimeUtils.WEEK_IN_MILLIS, // The maximum resolution at which the time will switch
// to default date instead of spans. This will not
// display "3 weeks ago" but a full date instead
0); // Eventual flags
为其他值 MINUTE_IN_MILLIS
和 YEAR_IN_MILLIS
包括:
-
SECOND_IN_MILLIS
-
MINUTE_IN_MILLIS
-
HOUR_IN_MILLIS
-
DAY_IN_MILLIS
-
WEEK_IN_MILLIS
-
YEAR_IN_MILLIS
- 以毫秒为单位的任何自定义值
SECOND_IN_MILLIS
MINUTE_IN_MILLIS
HOUR_IN_MILLIS
DAY_IN_MILLIS
WEEK_IN_MILLIS
YEAR_IN_MILLIS
- Any custom value in milliseconds
这篇关于安卓:getRelativeTime例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!