@@ -0,0 +1,1885 @@
+package com.anotherdev.stackapp.util;%0A%0Aimport android.text.format.DateUtils;%0A%0Aimport com.crashlytics.android.Crashlytics;%0Aimport com.google.common.collect.ImmutableList;%0A%0Aimport java.text.DateFormat;%0Aimport java.text.ParseException;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;%0Aimport java.util.Locale;%0A%0Apublic class Dates %7B%0A%0A    private static final String TAG = Dates.class.getSimpleName();%0A%0A    private static final String DATE_PATTERN_MICROSECOND = %22yyyy-MM-dd'T'HH:mm:ss.SSSZ%22;%0A    private static final String DATE_PATTERN_SECOND = %22yyyy-MM-dd'T'HH:mm:ssZ%22;%0A%0A    private static final SimpleDateFormat DATE_FORMAT_MICROSECOND =%0A            new SimpleDateFormat(DATE_PATTERN_MICROSECOND, Locale.getDefault());%0A    private static final SimpleDateFormat DATE_FORMAT_SECOND =%0A            new SimpleDateFormat(DATE_PATTERN_SECOND, Locale.getDefault());%0A%0A    private static final ImmutableList%3CSimpleDateFormat%3E DATE_FORMAT = ImmutableList.of(%0A            DATE_FORMAT_MICROSECOND,%0A            DATE_FORMAT_SECOND%0A    );%0A%0A%0A    public static CharSequence getTimeAgo(CharSequence text) %7B%0A        ParseException exception = null;%0A        for (DateFormat format : DATE_FORMAT) %7B%0A            // Workaround Java bug: http://stackoverflow.com/a/15231574/802421%0A            String fixed = String.valueOf(text).replaceAll(%22Z$%22, %22+0000%22);%0A            try %7B%0A                Date date = format.parse(fixed);%0A                return getTimeAgo(date.getTime());%0A            %7D catch (ParseException e) %7B%0A                exception = e;%0A            %7D%0A        %7D%0A        Crashlytics.logException(exception);%0A        return text;%0A    %7D%0A%0A%0A    public static CharSequence getTimeAgo(final long timeInSecond) %7B%0A        final long now = System.currentTimeMillis();%0A        final long timeInMillis = timeInSecond * 1000;%0A        return DateUtils.getRelativeTimeSpanString(timeInMillis, now, 0);%0A    %7D%0A%7D%0A

add dates util