private static BigDecimal getFactor(TimeUnit unit) {
    switch (unit) {
      case DAY:
        return BigDecimal.ONE;
      case HOUR:
        return TimeUnit.DAY.multiplier;
      case MINUTE:
        return TimeUnit.HOUR.multiplier;
      case SECOND:
        return TimeUnit.MINUTE.multiplier;
      case MILLISECOND:
      case MICROSECOND:
      case NANOSECOND:
        return TimeUnit.SECOND.multiplier;
      case YEAR:
        return BigDecimal.ONE;
      case MONTH:
        return TimeUnit.YEAR.multiplier;
      case QUARTER:
        return TimeUnit.YEAR.multiplier;
      case DECADE:
      case CENTURY:
      case MILLENNIUM:
        return BigDecimal.ONE;
      default:
        throw new IllegalArgumentException("Invalid start unit.");
    }
  }
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