获得两个日期之间的Andr​​oid的差异差异、日期、两个、Andr

由网友(怪我丑)分享简介:是:2011-03-27T09:39:01.607和有当前的日期。我想这两个日期之间差异的形式:I want to get difference between these two dates in the form of :2 days ago 1 minute ago etc..根据过帐日期。depen...

是:

2011-03-27T09:39:01.607

和有当前的日期。

我想这两个日期之间差异的形式:

I want to get difference between these two dates in the form of :

2 days ago 
1 minute ago etc..

根据过帐日期。

depending posting date.

现在用这个code张贴日期转换为钢厂秒:

Am using this code to convert posting date to mill seconds:

 public long Date_to_MilliSeconds(int day, int month, int year, int hour, int minute)
{

       Calendar c = Calendar.getInstance();

       c.set(year, month, day, hour, minute, 00);

        return c.getTimeInMillis();

}

这当前日期:长今= System.currentTimeMillis的();

和计算的区别:

 String difference =  (String) DateUtils.getRelativeTimeSpanString(time,now, 0);

但它返回像 1970年5月1日或东西..

如何获得过帐日期和当前日期之间的差异。

推荐答案

你得到1970年是因为它是在毫秒时代日期的理由。为了得到实际相差使用下面的。

The reason you get 1970 is because it is the epoch date in milli seconds. To get the actual difference use the below.

使用 JodaTime

阅读全文

相关推荐

最新文章