code: public static int compare(Date d1, Date d2) {
          Calendar c1 = Calendar.getInstance();
          c1.setTime(d1);
          Calendar c2 = Calendar.getInstance();
          c2.setTime(d2);
  
          if (c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) {
              if (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH)) {
                  return c1.get(Calendar.DAY_OF_MONTH) - c2.get(Calendar.DAY_OF_MONTH);
              }
              return c1.get(Calendar.MONTH) - c2.get(Calendar.MONTH);
          }
          return c1.get(Calendar.YEAR) - c2.get(Calendar.YEAR);
      }
docs: Compares two dates taking into consideration only the year, month and day
  @param d1 the first date
  @param d2 the second date
  @return a negative integer, zero, or a positive integer as
  <code>d1</code> is less than, equal to, or greater than <code>d2</code>
  @see java.util.Comparator
  @see #after(Date, Date)
  @see #before(Date, Date)