private static long divide(long res, BigDecimal value) {
    if (value.equals(BigDecimal.ONE)) {
      return res;
    } else if (value.compareTo(BigDecimal.ONE) < 0 && value.signum() == 1) {
      BigDecimal reciprocal = BigDecimal.ONE.divide(value, RoundingMode.UNNECESSARY);
      return reciprocal.multiply(BigDecimal.valueOf(res)).longValue();
    } else {
      return res / value.longValue();
    }
  }
Helper for CAST({date} AS VARCHAR(n)).
amoro-format-mixed/amoro-mixed-flink/amoro-mixed-flink-common/src/main/java/org/apache/amoro/flink/util/DateTimeUtils.java