code: private long compare(Object that) {
          long thatMs;
          if (that instanceof Calendar) {
              thatMs = ((Calendar)that).getTimeInMillis();
          } else if (that instanceof Date) {
              thatMs = ((Date)that).getTime();
          } else {
              throw new IllegalArgumentException(that + "is not a Calendar or Date");
          }
          return getTimeInMillis() - thatMs;
      }
docs: Returns the difference in milliseconds between the moment this
  calendar is set to and the moment the given calendar or Date object
  is set to.