I have android program that display the users comment using RecyclerView and CardView. And i have the TextView on every comment that display the time created in this format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' and i want the time to be displayed like "1 minutes ago", Now, 1 month ago, ...
i tried to implement by using the following codes
SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
// long time = s.parse("2016-01-24T16:00:00.000Z").getTime();
long time = 0;
try {
time = s.parse(timeNow).getTime();
} catch (ParseException e) {
e.printStackTrace();
}
long now = currentTimeMillis();
CharSequence ago = DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS);
Anyone with an idea on how to implement this can help me.