2

I'm using DateUtils to show the posted time. But is there a way to show:

"4 min ago" instead of "4 minutes ago"

        CharSequence result = DateUtils.getRelativeTimeSpanString(timestamp, Currenttime,DateUtils.SECOND_IN_MILLIS);
Joris
  • 119
  • 9
  • I think this post will help you http://stackoverflow.com/questions/19409035/custom-format-for-relative-time-span – Alvaro Feb 08 '17 at 14:13

1 Answers1

4

use

 getRelativeTimeSpanString (long time, 
                long now, 
                long minResolution, 
                int flags)

and provide as DateUtils.FORMAT_ABBREV_RELATIVE as flags.

Accordingly to the documentation

Can use FORMAT_ABBREV_RELATIVE flag to use abbreviated relative times, like "42 mins ago".

E.g.

CharSequence result = DateUtils.getRelativeTimeSpanString(timestamp, Currenttime,DateUtils.SECOND_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE);

should do it.

Blackbelt
  • 156,034
  • 29
  • 297
  • 305