Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MomentJS like functionality for Android Apps

Tags:

android

I have a record with date and time, and I would want to convert the transaction date from current date, differentiate and show number of days.

For e.g.

If the the record has got a date time, which is 1 hours before than Now, the system should show an hour ago...

Similarly if there is a record with 3 days before then instead of showing a date, I would want to show "3 days ago".

like image 594
codebased Avatar asked Mar 20 '15 15:03

codebased


1 Answers

No need to use any custom solution.

You can use android.text.format.DateUtils.getRelativeTimeSpanString

It returns a string describing 'time' as a time relative to 'now'.

reference: http://developer.android.com/reference/android/text/format/DateUtils.html

like image 167
codebased Avatar answered Oct 14 '22 20:10

codebased