@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    if (dateTypeArg) {
      return evaluateDate(arguments);
    } else {
      return evaluateNumber(arguments);
    }
  }
GenericUDFTrunc.

Returns the first day of the month which the date belongs to. The time part of the date will be
ignored.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTrunc.java