Mohamad Azrie Mohamad Azrie - 5 months ago 44
Java Question

Change format of DateUtils.Format_ABBREV_RELATIVE

Currently I have code where it return me the difference between two point of time by using

but I want to change the text of the returned text. Currently this is what I get :

17 min ago
9 hr ago
13 hr ago

But what I really want is

17 minutes ago
9 hours ago
13 hours ago

this is my code :

CharSequence time = DateUtils.getRelativeTimeSpanString(postTime,System.currentTimeMillis(),DateUtils.MINUTE_IN_MILLIS,DateUtils.FORMAT_ABBREV_RELATIVE);

Thank you for the help


For getting in specific format you need to change the flag.

change FORMAT_ABBREV_RELATIVE flag to FORMAT_NUMERIC_DATE. This will returns character sequence in format you want.