class TimestampToString implements Kudf {

  @Override
  public Object evaluate(Object... args) {
    if (args.length != 2) {
      throw new KsqlFunctionException("TimestampToString udf should have two input argument:"
                                      + " date value and format.");
    }

    try {
      ensureInitialized(args);

      final Timestamp timestamp = new Timestamp((Long) args[0]);
      return timestamp.toLocalDateTime()
          .atZone(ZoneId.systemDefault())
          .format(threadSafeFormatter);
    } catch (Exception e) {
      throw new KsqlFunctionException("Exception running TimestampToString(" + args[0] + " , "
                                      + args[1] + ") : " + e.getMessage(), e);
    }
  }

}