Formatting of DateUtils.getRelativeDateTimeString

I have used a different method and gotten the "in 23 hours" result I wanted

DateUtils.getRelativeTimeSpanString(due,now, DateUtils.SECOND_IN_MILLIS)

According to Android Documentation, you'll need to add a flag to display "42 mins ago", instead of "42 mins ago 01/01/2020".

DateUtils.getRelativeTimeSpanString(
    item.createdAt.time,
    Date().time,
    DateUtils.MINUTE_IN_MILLIS,
    FORMAT_ABBREV_RELATIVE
)

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

https://developer.android.com/reference/android/text/format/DateUtils#getRelativeTimeSpanString(long,%20long,%20long,%20int)

Tags:

Android