@Udf(description = "Converts a string representation of a date in the given format"
      + " into the number of days since 1970-01-01 00:00:00 UTC/GMT.")
  public int stringToDate(
      @UdfParameter(
          description = "The string representation of a date.") final String formattedDate,
      @UdfParameter(
          description = "The format pattern should be in the format expected by"
              + " java.time.format.DateTimeFormatter.") final String formatPattern) {
    // NB: We do not perform a null here preferring to throw an exception as
    // there is no sentinel value for a "null" Date.
    try {
      final DateTimeFormatter formatter = formatters.get(formatPattern);
      return ((int)LocalDate.parse(formattedDate, formatter).toEpochDay());
    } catch (final ExecutionException | RuntimeException e) {
      throw new KsqlFunctionException("Failed to parse date '" + formattedDate
          + "' with formatter '" + formatPattern
          + "': " + e.getMessage(), e);
    }
  }
@Test
  public void shouldConvertCaseInsensitiveStringToDate() {
    // When:
    final int result = udf.stringToDate("01-dec-2021", "dd-MMM-yyyy");

    // Then:
    assertThat(result, is(18962));
  }