app/src/main/java/com/vehiclerental/utils/DateUtils.java
/**
     * Compare two calendars without time comparison
     * @param cal1 first calendar
     * @param cal2 second calendar
     * @return DATE1_EQUAL_DATE2 if the dates are the same, DATE1_BEFORE_DATE2 if the date1 is before date2 and DATE1_AFTER_DATE2 otherwise
     */
Compare two calendars without time comparison
@param cal1 first calendar
@param cal2 second calendar
@return DATE1_EQUAL_DATE2 if the dates are the same, DATE1_BEFORE_DATE2 if the date1 is before date2 and DATE1_AFTER_DATE2 otherwise
Compare two calendars without time comparison @param cal1 first calendar @param cal2 second calendar @return DATE1_EQUAL_DATE2 if the dates are the same DATE1_BEFORE_DATE2 if the date1 is before date2 and DATE1_AFTER_DATE2 otherwise
public static int compareCalendar(Calendar cal1, Calendar cal2) {
        if (cal1 == null || cal2 == null) {
            return 0;
        }
        if (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA)
                && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)) {
            return DATE1_EQUAL_DATE2;
        }
        if (cal1.get(Calendar.ERA) < cal2.get(Calendar.ERA)
                || cal1.get(Calendar.YEAR) < cal2.get(Calendar.YEAR)
                || cal1.get(Calendar.DAY_OF_YEAR) < cal2.get(Calendar.DAY_OF_YEAR)) {
            return DATE1_BEFORE_DATE2;
        }
        return DATE1_AFTER_DATE2;
    }
public static int compareCalendar ( Calendar cal1 , Calendar cal2 ) { if ( cal1 == null || cal2 == null ) { return 0 ; } if ( cal1 . get ( Calendar . ERA ) == cal2 . get ( Calendar . ERA ) && cal1 . get ( Calendar . YEAR ) == cal2 . get ( Calendar . YEAR ) && cal1 . get ( Calendar . DAY_OF_YEAR ) == cal2 . get ( Calendar . DAY_OF_YEAR ) ) { return DATE1_EQUAL_DATE2 ; } if ( cal1 . get ( Calendar . ERA ) < cal2 . get ( Calendar . ERA ) || cal1 . get ( Calendar . YEAR ) < cal2 . get ( Calendar . YEAR ) || cal1 . get ( Calendar . DAY_OF_YEAR ) < cal2 . get ( Calendar . DAY_OF_YEAR ) ) { return DATE1_BEFORE_DATE2 ; } return DATE1_AFTER_DATE2 ; }
Compare two calendars without time comparison
 @param cal1 first calendar
 @param cal2 second calendar
 @return DATE1_EQUAL_DATE2 if the dates are the same, DATE1_BEFORE_DATE2 if the date1 is before date2 and DATE1_AFTER_DATE2 otherwise
Compare two calendars without time comparison @param cal1 first calendar @param cal2 second calendar @return DATE1_EQUAL_DATE2 if the dates are the same DATE1_BEFORE_DATE2 if the date1 is before date2 and DATE1_AFTER_DATE2 otherwise