3

I am using the getRelativeTimeSpanString(...) to get time back in X seconds ago X hours ago etc.

However, when the difference between the two times is short - minutes or seconds, then it is returning in 10 hours instead of X minutes ago

Here is how I'm using it:

Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH)
                                .parse("2014-05-21 13:07:11");
Date currentDate = new Date();
CharSequence cs =  DateUtils.getRelativeTimeSpanString(date.getTime(), 
                                 currentDate.getTime(), DateUtils.SECOND_IN_MILLIS);
birdy
  • 9,286
  • 24
  • 107
  • 171
  • it means that the differences between the two are negative (so it read it as future) And you can use System.currentTimeMillis() instead of currentDate = new Date() – Marco Acierno May 21 '14 at 17:18
  • dope...you are right. The time on my emulator was wrong. I'll keep the question open in-case someone else goes through this :) – birdy May 21 '14 at 17:22
  • It might be an issue of `TimeZone`. – unknown May 21 '14 at 17:30

0 Answers0