Java Utililty Methods Day Compare

List of utility methods to do Day Compare

Description

The list of methods to do Day Compare are organized into topic(s).

Method

booleanisSameDay(Date date1, Date date2)
is Same Day
return date2String(date1, "yyyy-MM-dd").equals(date2String(date2, "yyyy-MM-dd"));
booleanisSameDay(Date date1, Date date2)
is Same Day
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
return fmt.format(date1).equals(fmt.format(date2));
booleanisSameDay(Date date1, Date date2)
Checks if two dates are the same day
if (date1 == null || date2 == null) {
    return false;
Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
Calendar cal2 = Calendar.getInstance();
cal2.setTime(date2);
return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
...
booleanisSameDay(Date date1, Date date2)
is Same Day
int flag = compareDate(date1, date2, "yy-MM-dd");
return flag == 0 ? true : false;
booleanisSameDay(Date day1, Date day2)
is Same Day
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String ds1 = sdf.format(day1);
String ds2 = sdf.format(day2);
if (ds1.equals(ds2)) {
    return true;
} else {
    return false;
booleanisSameDay(Date day1, Date day2)
is Same Day
return SHORT_DATE_FORMAT.format(day1).equals(SHORT_DATE_FORMAT.format(day2));
booleanisSameDay(Date preDate, Date postDate)
is Same Day
return dateToString(preDate, YYYY_MM_DD).equals(dateToString(postDate, YYYY_MM_DD));
booleanisSameDay(final Date date1, final Date date2)
is Same Day
return stripTime(date1).equals(stripTime(date2));
booleanisSameDay(final Date date1, final Date date2)
Checks two dates to see if they are the same calendar day.
return DAY_FORMAT.format(date1).equals(DAY_FORMAT.format(date2));
booleansameDay(Date d1, Date d2)
test two dates have the same day
if (d1.getYear() != d2.getYear())
    return false;
if (d1.getMonth() != d2.getMonth())
    return false;
if (d1.getDay() != d2.getDay())
    return false;
return true;