private long truncate(Timestamp ts, HiveIntervalDayTime idt, Timestamp origin) {
    long intervalDurationMs = idt.getTotalSeconds() * 1000L + idt.getNanos() / 1000L;
    long offset = ts.toEpochMilli() % intervalDurationMs - origin.toEpochMilli() % intervalDurationMs;
    if (offset < 0) {
      offset += intervalDurationMs;
    }
    return ts.toEpochMilli() - offset;
  }
Evaluate the GenericUDF with the arguments.

@param arguments timestamp and interval.

@return The truncated timestamp to the beginning of tumbled window interval.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTumbledWindow.java