Find Different Between to Date in days in android

Dtae like ="03-06-2015"

public long getDiffrent(String date) {

        String[] arraydtae= new String[3];
        arraydtae= datenew.split("-"); // Hear you require to define date-month separator like hear "-"

        int dd = Integer.parseInt(arra[0]);
        int mm = Integer.parseInt(arra[1]);
        int yy = Integer.parseInt(arra[2]);

        Calendar thatDay = Calendar.getInstance();
        thatDay.set(Calendar.DAY_OF_MONTH, dd);
        thatDay.set(Calendar.MONTH, mm - 1); // 0-11 so 1 less
        thatDay.set(Calendar.YEAR, yy);

       Calendar today = Calendar.getInstance();
        long diff = today.getTimeInMillis() - thatDay.getTimeInMillis(); //result in millis
        long days = diff / (24 * 60 * 60 * 1000);
     
        return days;
}

No comments: