public static Timestamp decimalToTimestamp(
      HiveDecimalWritable decWritable,
      HiveDecimalWritable scratchDecWritable1, HiveDecimalWritable scratchDecWritable2) {

    HiveDecimalWritable nanosWritable = scratchDecWritable1;
    nanosWritable.set(decWritable);
    nanosWritable.mutateFractionPortion();               // Clip off seconds portion.
    nanosWritable.mutateScaleByPowerOfTen(9);            // Bring nanoseconds into integer portion.
    if (!nanosWritable.isSet() || !nanosWritable.isInt()) {
      return null;
    }
    int nanos = nanosWritable.intValue();
    if (nanos < 0) {
      nanos += 1000000000;
    }
    nanosWritable.setFromLong(nanos);

    HiveDecimalWritable nanoInstant = scratchDecWritable2;
    nanoInstant.set(decWritable);
    nanoInstant.mutateScaleByPowerOfTen(9);

    nanoInstant.mutateSubtract(nanosWritable);
    nanoInstant.mutateScaleByPowerOfTen(-9);              // Back to seconds.
    if (!nanoInstant.isSet() || !nanoInstant.isLong()) {
      return null;
    }
    long seconds = nanoInstant.longValue();

    return Timestamp.ofEpochSecond(seconds, nanos);
  }
Take a HiveDecimalWritable and return the timestamp representation where the fraction part
is the nanoseconds and integer part is the number of seconds.

This is a HiveDecimalWritable variation with supplied scratch objects.
@param decWritable
@param scratchDecWritable1
@param scratchDecWritable2
@return
common/src/java/org/apache/hadoop/hive/common/type/TimestampUtils.java