public TimestampLocalTZWritable evaluate(TimestampLocalTZWritable t) {
    if (t == null) {
      return null;
    }
    final ZonedDateTime localZDT = t.getTimestampTZ().getZonedDateTime(); // default
    final long originalTimestampUTC = localZDT.withZoneSameLocal(ZoneOffset.UTC)
        .toInstant().toEpochMilli(); // default -> utc
    final long newTimestampUTC = granularity.truncate(originalTimestampUTC); // utc
    final ZonedDateTime newLocalZDT = ZonedDateTime.of(
        LocalDateTime.ofInstant(Instant.ofEpochMilli(newTimestampUTC), ZoneOffset.UTC),
        localZDT.getZone()); // utc -> default
    resultTSLTZ.set(new TimestampTZ(newLocalZDT));
    return resultTSLTZ;
  }
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