public static TimestampData truncate(TimestampData ts, int precision) {
    String fraction = Integer.toString(ts.toLocalDateTime().getNano());
    if (fraction.length() <= precision) {
      return ts;
    } else {
      // need to truncate
      if (precision <= 3) {
        return TimestampData.fromEpochMillis(zeroLastDigits(ts.getMillisecond(), 3 - precision));
      } else {
        return TimestampData.fromEpochMillis(
            ts.getMillisecond(), (int) zeroLastDigits(ts.getNanoOfMillisecond(), 9 - precision));
      }
    }
  }
Appends year-month-day to a buffer; assumes they are valid.
amoro-format-mixed/amoro-mixed-flink/amoro-mixed-flink-common/src/main/java/org/apache/amoro/flink/util/DateTimeUtils.java