public TimestampWritableV2 evaluate(TimestampWritableV2 t) {
    if (t == null) {
      return null;
    }
    final long originalTimestamp = t.getTimestamp().toEpochMilli();
    final long newTimestamp = granularity.truncate(originalTimestamp);
    resultTS.set(Timestamp.ofEpochMilli(newTimestamp));
    return resultTS;
  }
UDFDateFloor.

Abstract class that converts a timestamp to a timestamp with a given granularity.
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFDateFloor.java