public static Timestamp decimalToTimestamp(HiveDecimal dec) {

    HiveDecimalWritable nanosWritable = new HiveDecimalWritable(dec);
    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 = new HiveDecimalWritable(dec);
    nanoInstant.mutateScaleByPowerOfTen(9);

    nanoInstant.mutateSubtract(nanosWritable);
    nanoInstant.mutateScaleByPowerOfTen(-9);              // Back to seconds.
    if (!nanoInstant.isSet() || !nanoInstant.isLong()) {
      return null;
    }
    long seconds = nanoInstant.longValue();
    Timestamp t = new Timestamp(seconds * 1000);
    t.setNanos(nanos);
    return t;
  }
Take a HiveDecimal and return the timestamp representation where the fraction part is the
nanoseconds and integer part is the number of seconds.
@param dec
@return
storage-api/src/java/org/apache/hadoop/hive/ql/util/TimestampUtils.java