code: private boolean isThisDateValid(String dateToValidate, String dateFromat) {
          if (dateToValidate == null) {
              return false;
          }
          SimpleDateFormat sdf = new SimpleDateFormat(dateFromat);
          sdf.setLenient(false);
          try {
              //if not valid, it will throw ParseException
              Date date = sdf.parse(dateToValidate);
          } catch (ParseException e) {
              e.printStackTrace();
              return false;
          }
          return true;
      }
docs: Check is a String is a valid timestamp format
  @param dateToValidate
  @param dateFromat
  @return true/false