以下代码返回“1月1日”,当它应该返回“8月8日”或确切地说是“片刻之前”:
long now = System.currentTimeMillis();
long time = mDataset.get(position).Time.getTime();
String Time = (String) DateUtils.getRelativeTimeSpanString(time,now,0L,DateUtils.FORMAT_ABBREV_ALL);
有什么想法吗?
答案 0 :(得分:0)
long now = System.currentTimeMillis();
//HERE IS THE PROBLEM => long time = mDataset.get(position).Time.getTime();
long threeSecondsAgo = System.currentTimeMillis() - 3000;
String time = (String) DateUtils.getRelativeTimeSpanString(threeSecondsAgo, now, 0L, DateUtils.FORMAT_ABBREV_ALL);
Log.d("time", time);
记录结果=>时间:3秒前
长时间的价值是多少?你可以调试或提供mDataset填充方法吗?