我想在我的應用中使用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
等。
它沒有正確計算差異。
缺什麼?