Best way to format a date relative to now on Android

前端 未结 10 1712
隐瞒了意图╮
隐瞒了意图╮ 2021-01-31 15:57

I am creating a feature in an Android app to get an arbitrary date (past, present or future) and find the difference relative to now.

Both my now and

10条回答
  •  抹茶落季
    2021-01-31 16:37

    What I have in mind is changing:

    DateUtils.getRelativeTimeSpanString(due, now, 0L, DateUtils.FORMAT_ABBREV_ALL);

    Since the documentation says it returns the time relative to now.

    If that fails use some of the brilliant libraries:

    Joda Time

    PrettyTime

    TimeAgo

提交回复
热议问题