package com.commit451.gitlab.util;

import android.content.Context;

import com.commit451.gitlab.R;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Our own DateUtils, which call forwards to {@link android.text.format.DateUtils} with some
 * nice defaults
 */
public class DateUtils {

    private static DateFormat FORMATTER = new SimpleDateFormat("HH:mm:ss");

    public static CharSequence getRelativeTimeSpanString(Context context, Date startTime) {
        Date now = new Date();
        if (Math.abs(now.getTime() - startTime.getTime()) < android.text.format.DateUtils.SECOND_IN_MILLIS) {
            return context.getString(R.string.just_now);
        }

        return android.text.format.DateUtils.getRelativeTimeSpanString(startTime.getTime(),
                now.getTime(),
                android.text.format.DateUtils.SECOND_IN_MILLIS)
                .toString();
    }

    public static String getTimeTaken(Date startTime, Date endTime) {
        Date timeTaken = new Date(endTime.getTime() - startTime.getTime());
        return FORMATTER.format(timeTaken);
    }
}

@@ -110,23 +110,17 @@
 ava.
-text
+util
 .Date
-Format
 ;%0Aim
@@ -133,52 +133,32 @@
 ava.
-text.SimpleDateFormat;%0Aimport java.util.Date
+util.concurrent.TimeUnit
 ;%0A%0A/
@@ -274,16 +274,16 @@
 lts%0A */%0A
+
 public c
@@ -304,85 +304,8 @@
  %7B%0A%0A
-    private static DateFormat FORMATTER = new SimpleDateFormat(%22HH:mm:ss%22);%0A%0A
     
@@ -906,117 +906,135 @@
     
-Date timeTaken = new Date(endTime.getTime() - startTime.getTime());%0A        return FORMATTER.format(timeTaken
+return android.text.format.DateUtils.formatElapsedTime(TimeUnit.MILLISECONDS.toSeconds(endTime.getTime() - startTime.getTime())
 );%0A 

Format time elapsed properly