@Udf(description = "Converts a TIME value into the"
      + " string representation of the time in the given format."
      + " The format pattern should be in the format expected"
      + " by java.time.format.DateTimeFormatter")
  public String formatTime(
      @UdfParameter(
          description = "TIME value.") final Time time,
      @UdfParameter(
          description = "The format pattern should be in the format expected by"
              + " java.time.format.DateTimeFormatter.") final String formatPattern) {
    if (time == null || formatPattern == null) {
      return null;
    }
    try {
      final DateTimeFormatter formatter = formatters.get(formatPattern);
      return LocalTime.ofNanoOfDay(TimeUnit.MILLISECONDS.toNanos(time.getTime())).format(formatter);
    } catch (ExecutionException | RuntimeException e) {
      throw new KsqlFunctionException("Failed to format time "
          + LocalTime.ofNanoOfDay(time.getTime() * 1000000)
          + " with formatter '" + formatPattern
          + "': " + e.getMessage(), e);
    }
  }
@Test
  public void shouldConvertTimeToString() {
    // When:
    final String result = udf.formatTime(new Time(65000), "HHmmss");

    // Then:
    assertThat(result, is("000105"));
  }