Skip to content

Instantly share code, notes, and snippets.

@msomu
Created September 25, 2015 20:09
Show Gist options
  • Select an option

  • Save msomu/f98b68b469c82f52de1d to your computer and use it in GitHub Desktop.

Select an option

Save msomu/f98b68b469c82f52de1d to your computer and use it in GitHub Desktop.
A small time util to convert TimeStamp into momments ago
public void setTime(String time) {
if (!TextUtils.isEmpty(time)) {
CharSequence relativeTimeSpanString = DateUtils.getRelativeTimeSpanString(Long.valueOf(time), System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE);
this.time = relativeTimeSpanString.toString();
} else {
this.time = "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment