Java Utililty Methods Date Equal

List of utility methods to do Date Equal

Description

The list of methods to do Date Equal are organized into topic(s).

Method

booleanhourEqual(Date date1, Date date2)
hour Equal
if (date1 == null || date2 == null) {
    return false;
Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
Calendar cal2 = Calendar.getInstance();
cal1.setTime(date2);
if (cal1.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY)) {
...
booleanisEqual(Date date1, Date date2)
Checks if date1 is equal date2.
int[] dIng1 = getDateIngredients(date1);
int[] dIng2 = getDateIngredients(date2);
if (dIng1[0] == dIng2[0] && dIng1[1] == dIng2[1] && dIng1[2] == dIng2[2]) {
    return true;
return false;
booleanisEqualByDay(Date date1, Date date2)
is Equal By Day
Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
Calendar cal2 = Calendar.getInstance();
cal2.setTime(date2);
return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
        && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR);
booleanisEqualDate(Date date1, Date date2)
is Equal Date
if (date1 == null || date2 == null) {
    return false;
GregorianCalendar cal1 = new GregorianCalendar();
cal1.setTime(date1);
GregorianCalendar cal2 = new GregorianCalendar();
cal2.setTime(date2);
return cal1.get(Calendar.YEAR) == cal1.get(Calendar.YEAR)
...
booleanisEqualField(int field, Date d1, Date d2)
is Equal Field
Calendar c1 = Calendar.getInstance();
c1.setTime(d1);
Calendar c2 = Calendar.getInstance();
c2.setTime(d2);
return c1.get(field) == c2.get(field);
booleanisLowerEqualDate(Date date)
is Lower Equal Date
long ms = date.getTime() - getCurDateTime().getTime();
return ms <= 0;
booleanisSameDate(Date date, Date date1)
is Same Date
return getDateField(date, Calendar.YEAR) == getDateField(date1, Calendar.YEAR)
        && getDateField(date, Calendar.MONTH) == getDateField(date1, Calendar.MONTH)
        && getDateField(date, Calendar.DATE) == getDateField(date1, Calendar.DATE);
booleanisSameDate(Date date1, Date date2)
Returns true if the 2 dates are the same, regardless of the time
if (date1 == null || date2 == null) {
    return false;
Calendar c1 = (GregorianCalendar) Calendar.getInstance();
c1.setTime(date1);
c1.set(Calendar.HOUR_OF_DAY, 0);
c1.set(Calendar.MINUTE, 0);
c1.set(Calendar.SECOND, 0);
...
booleanisSameDate(Date pathDate, Date now)
is Same Date
Calendar c = Calendar.getInstance();
c.setTime(pathDate);
Calendar nowCalendar = Calendar.getInstance();
nowCalendar.setTime(now);
return c.get(Calendar.DAY_OF_YEAR) == nowCalendar.get(Calendar.DAY_OF_YEAR)
        && c.get(Calendar.YEAR) == nowCalendar.get(Calendar.YEAR);
booleanisSameDate(long var0, long var2)
is Same Date
return isSameDate(var0, var2, 5);