@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    Integer numMonthV;
    if (isNumMonthsConst) {
      numMonthV = numMonthsConst;
    } else {
      numMonthV = getIntValue(arguments, 1, tsConverters);
    }

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

    int numMonthInt = numMonthV.intValue();

    // 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) {
      addMonth(ts, numMonthInt);
    } else {
      Date date = getDateValue(arguments, 0, dtConverters);
      if (date != null) {
        addMonth(date, numMonthInt);
      } else {
        return null;
      }
    }

    String res = formatter.format(calendar.getTime());

    output.set(res);
    return output;
  }
GenericUDFAddMonths.

Add a number of months to the date. The time part of the string will be
ignored.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFAddMonths.java