@Udf(description = "Converts the number of days since 1970-01-01 00:00:00 UTC/GMT to a date "
      + "string using the given format pattern. The format pattern should be in the format"
      + " expected by java.time.format.DateTimeFormatter")
  public String dateToString(
      @UdfParameter(
          description = "The Epoch Day to convert,"
              + " based on the epoch 1970-01-01") final int epochDays,
      @UdfParameter(
          description = "The format pattern should be in the format expected by"
              + " java.time.format.DateTimeFormatter.") final String formatPattern) {
    if (formatPattern == null) {
      return null;
    }
    try {
      final DateTimeFormatter formatter = formatters.get(formatPattern);
      return LocalDate.ofEpochDay(epochDays).format(formatter);
    } catch (final ExecutionException | RuntimeException e) {
      throw new KsqlFunctionException("Failed to format date " + epochDays
          + " with formatter '" + formatPattern
          + "': " + e.getMessage(), e);
    }
  }
@Test
  public void shouldByThreadSafeAndWorkWithManyDifferentFormatters() {
    IntStream.range(0, 10_000)
        .parallel()
        .forEach(idx -> {
          try {
            final String pattern = "yyyy-MM-dd'X" + idx + "'";
            final String result = udf.dateToString(18765, pattern);
            assertThat(result, is("2021-05-18X" + idx));
          } catch (final Exception e) {
            fail(e.getMessage());
          }
        });
  }