package com.example.daniel.todule_android.utilities;

/**
 * Created by danieL on 9/29/2017.
 */

public final class DateTimeUtils {

    private DateTimeUtils(){}

    public static long millisDiffFromNow (long then) {
        long now = System.currentTimeMillis();
        return then - now;
    }

    public static String dateTimeDiff (long then) {
        String result;
        String pastOrFuture;
        long diff = millisDiffFromNow(then);
        if (diff < 0 ) {
            pastOrFuture = " ago";
        } else {
            pastOrFuture = " left";
        }
        diff = Math.abs(diff);
        long diffInSeconds = diff / 1000;
        long diffInMinutes = diffInSeconds / 60;
        long diffInHours = diffInMinutes / 60;
        long diffInDays = diffInHours / 24;
        if (diffInDays >= 1) {
            result = String.valueOf(diffInDays);
            result += (diffInDays == 1) ? " day" : " days";
        } else if (diffInHours >= 1) {
            result = String.valueOf(diffInHours);
            result += (diffInHours == 1) ? " hour" : " hours";
        } else if (diffInMinutes >= 1) {
            result = String.valueOf(diffInMinutes);
            result += (diffInMinutes == 1) ? " minute" : " minutes";
        } else {
            result = String.valueOf(diffInSeconds);
            result += (diffInSeconds == 1) ? " second" : " seconds";
        }
        return result + pastOrFuture;

    }
}

@@ -1058,21 +1058,170 @@
  %22 h
-ou
 r
+ 
 %22 : %22 h
-our
+rs %22;%0A            long minutes = diffInMinutes %25 60;%0A            result += String.valueOf(minutes);%0A            result += (minutes == 1) ? %22 min%22 : %22 min
 s%22;%0A
@@ -1363,19 +1363,16 @@
  ? %22 min
-ute
 %22 : %22 mi
@@ -1372,19 +1372,16 @@
  : %22 min
-ute
 s%22;%0A    

Change countdown util