@Override
  public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    checkArgsSize(arguments, 2, 2);

    checkArgPrimitive(arguments, 0);
    checkArgPrimitive(arguments, 1);

    // the function should support both short date and full timestamp format
    // time part of the timestamp should not be skipped
    checkArgGroups(arguments, 0, tsInputTypes, STRING_GROUP, DATE_GROUP);
    checkArgGroups(arguments, 1, tsInputTypes, STRING_GROUP);

    obtainTimestampConverter(arguments, 0, tsInputTypes, tsConverters);

    HiveConf conf = SessionState.getSessionConf();
    if (formatter == null) {
      formatter = InstantFormatter.ofConfiguration(conf);
    }
    if (timeZone == null) {
      timeZone = conf.getLocalTimeZone();
    }
    if (arguments[1] instanceof ConstantObjectInspector) {
      fmtStr = getConstantStringValue(arguments, 1);
    } else {
      throw new UDFArgumentTypeException(1, getFuncName() + " only takes constant as " + getArgOrder(1) + " argument");
    }

    return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
  }
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