@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    if (fmtStr == null) {
      return null;
    }

    // the function should support both short date and full timestamp format
    // time part of the timestamp should not be skipped
    Timestamp ts = getTimestampValue(arguments, 0, tsConverters);

    if (ts == null) {
      return null;
    }

    try {
      String res = formatter.format(TimestampTZUtil.convert(ts, timeZone).toInstant(), fmtStr);
      output.set(res);
      return output;
    } catch (RuntimeException e) {
      return null;
    }
  }
GenericUDFDateFormat.

converts a date/timestamp/string to a value of string in the format specified
by the java date format
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFDateFormat.java