code: private static boolean isSameDate(String date1, String date2, String separator) {
  
          date2 = date2.replace(separator, "");
          if (date2.equals("0229")) {
              try {
                  int year1 = Integer.parseInt(date1.substring(2, 4));
                  if (year1 % 4 != 0) {
                      return date1.endsWith("0228");
                  }
              } catch (Exception e) {
                  return false;
              }
          }
  
          return date1.endsWith(date2);
      }
docs: To check if two input date string is same date with no matter about 2nd
  input's separator
  
  @param date1 1st input date string with format yyyymmdd
  @param date2 2nd input date string with format mmdd or mm-dd
  @param separator The separator used in 2nd string
  @return comparison result