@Udf(description = "Converts a string representation of a date in the given format"
      + " into a DATE value.")
  public Date parseDate(
      @UdfParameter(
          description = "The string representation of a date.") final String formattedDate,
      @UdfParameter(
          description = "The format pattern should be in the format expected by"
              + " java.text.SimpleDateFormat.") final String formatPattern) {
    if (formattedDate == null || formatPattern == null) {
      return null;
    }
    try {
      final long time = formatters.get(formatPattern).parse(formattedDate).getTime();
      if (time % MILLIS_IN_DAY != 0) {
        throw new KsqlFunctionException("Date format contains time field.");
      }
      return new Date(time);
    } catch (final ExecutionException | RuntimeException | ParseException e) {
      throw new KsqlFunctionException("Failed to parse date '" + formattedDate
          + "' with formatter '" + formatPattern
          + "': " + e.getMessage(), e);
    }
  }
@Test
  public void shouldConvertCaseInsensitiveStringToDate() {
    // When:
    final Date result = udf.parseDate("01-dec-2021", "dd-MMM-yyyy");

    // Then:
    assertThat(result.getTime(), is(1638316800000L));
  }