import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
package com.yelinaung.android.utils;

public class DateUtils {

    public static String getDateDifference(Date thenDate) throws ParseException {
        long diff;

        Calendar now = Calendar.getInstance();
        Calendar then = Calendar.getInstance();

        now.setTime(new Date());
        then.setTime(thenDate);

        // Get the represented date in milliseconds
        long nowMs = now.getTimeInMillis();
        long thenMs = then.getTimeInMillis();

        // Calculate difference in milliseconds
        diff = nowMs - thenMs;

        // Calculate difference in seconds
        long diffMinutes = diff / (60 * 1000);
        long diffHours = diff / (60 * 60 * 1000);
        long diffDays = diff / (24 * 60 * 60 * 1000);

        if (diffMinutes < 60) {
            if (diffMinutes == 1)
            {
                return diffMinutes + " M";
            }
            else {
                return diffMinutes + " M";
            }
        } else if (diffHours < 24) {
            if (diffHours == 1)
                return diffHours + " hr";
            else
                return diffHours + " hr";
        } else if (diffDays < 30) {
            if (diffDays == 1)
            {
                return diffDays + " D";
            }
            else if ( diffDays < 10)
            {
                return diffDays + " D";
            }
            else
            {

                return now_d(thenDate).toString();
            }
        } else {
            return now_d(thenDate).toString();

        }
    }

    public static String DateToString(Date thenDate , mFormat) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(thenDate);
        //example MFormat = EEEE:MM:yyyy
        SimpleDateFormat df = new SimpleDateFormat(mFormat, Locale.ENGLISH);
        return df.format(cal.getTime());
    }

}
@@ -1,24 +1,62 @@
+package com.yelinaung.android.utils;%0A%0A
 import java.text.ParseEx
@@ -178,44 +178,8 @@
 le;%0A
-package com.yelinaung.android.utils;
 %0A%0Apu
@@ -945,36 +945,24 @@
 inutes == 1)
-%0A           
  %7B%0A         
@@ -1004,36 +1004,24 @@
            %7D
-%0A           
  else %7B%0A    
@@ -1309,28 +1309,16 @@
 ys == 1)
-%0A           
  %7B%0A     
@@ -1361,36 +1361,24 @@
            %7D
-%0A           
  else if ( d
@@ -1375,17 +1375,16 @@
 lse if (
- 
 diffDays
@@ -1389,28 +1389,16 @@
 ys %3C 10)
-%0A           
  %7B%0A     
@@ -1449,37 +1449,13 @@
    %7D
-%0A            else%0A           
+ else
  %7B%0A%0A
@@ -1652,17 +1652,16 @@
 thenDate
- 
 , mForma

rearrange code format