我想在我的应用中使用joda
API与Date
对象玩。在两秒钟内获得两个乔达日期之间的差异
在一些活动我正在存储joda
日期时间在sharedpreference
使用以下代码
prefsEdit.putLong(context.getString(R.string.last_status_change_time_key) , DateTime.now().getMillis());
现在,在一些其他的活动,即时消息获取该存储的偏好,并使用计算日期之间的差以下代码
long lastStatusChangeTime = objSharedPref.GetAppLongPrefByKey(R.string.last_status_change_time_key);
DateTime now = DateTime.now();
DateTime dateTime = new DateTime(lastStatusChangeTime);
Seconds seconds = Seconds.secondsBetween(now, dateTime);
int n = seconds.getSeconds();
代码总是返回我的值minus
例如-31
,-12
等。
它没有正确计算差异。
缺什么?