@Override
  public IntWritable evaluate(DeferredObject[] arguments) throws HiveException {

    Timestamp ts1 = getTimestampValue(arguments, 0, tsConverters);
    Timestamp ts2 = getTimestampValue(arguments, 1, tsConverters);

    if (ts1 == null || ts2 == null) {
      return null;
    }

    output.set(DateWritableV2.millisToDays(ts1.toEpochMilli()) - DateWritableV2.millisToDays(ts2.toEpochMilli()));
    return output;
  }
UDFDateDiff.

Calculate the difference in the number of days. The time part of the string
will be ignored. If dateString1 is earlier than dateString2, then the
result can be negative.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFDateDiff.java