protected DoubleWritable trunc(DoubleWritable input, int scale) {
    BigDecimal bigDecimal = new BigDecimal(input.get());
    BigDecimal trunc = trunc(bigDecimal, scale);
    DoubleWritable doubleWritable = new DoubleWritable(trunc.doubleValue());
    return doubleWritable;
  }
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