public static String getPartitionRangeString(DynamicPartitionProperty property, ZonedDateTime current,
                                                 int offset, String format) {
        String timeUnit = property.getTimeUnit();
        if (timeUnit.equalsIgnoreCase(TimeUnit.HOUR.toString())) {
            return getPartitionRangeOfHour(current, offset, format);
        } else if (timeUnit.equalsIgnoreCase(TimeUnit.DAY.toString())) {
            return getPartitionRangeOfDay(current, offset, format);
        } else if (timeUnit.equalsIgnoreCase(TimeUnit.WEEK.toString())) {
            return getPartitionRangeOfWeek(current, offset, property.getStartOfWeek(), format);
        } else if (timeUnit.equalsIgnoreCase(TimeUnit.MONTH.toString())) {
            return getPartitionRangeOfMonth(current, offset, property.getStartOfMonth(), format);
        } else if (timeUnit.equalsIgnoreCase(TimeUnit.YEAR.toString())) {
            return getPartitionRangeOfYear(current, offset, 1, format);
        }
        return null;
    }
@Test
    public void testGetPartitionRangeString() throws DateTimeException {
        // TimeUnit: DAY

        // 1. 2020-05-25, offset -7
        DynamicPartitionProperty property = new DynamicPartitionProperty(getDynamProp("DAY", -3, 3, -1, -1));
        String res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-25"), -7,
                FORMAT);
        Assert.assertEquals("2020-05-18", res);
        String partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "DAY");
        Assert.assertEquals("20200518", partName);
        // 2. 2020-05-25, offset 0
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-25"), 0,
                FORMAT);
        Assert.assertEquals("2020-05-25", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "DAY");
        Assert.assertEquals("20200525", partName);
        // 3. 2020-05-25, offset 7
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-25"), 7,
                FORMAT);
        Assert.assertEquals("2020-06-01", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "DAY");
        Assert.assertEquals("20200601", partName);
        // 4. 2020-02-28, offset 3
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-02-28"), 3,
                FORMAT);
        Assert.assertEquals("2020-03-02", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "DAY");
        Assert.assertEquals("20200302", partName);

        // TimeUnit: WEEK
        // 0. 2023-01-31 start day: WEDNESDAY, offset 0
        property = new DynamicPartitionProperty(getDynamProp("WEEK", -3, 3, 3, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2023-01-31"), 0,
                FORMAT);
        Assert.assertEquals("2023-01-25", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "WEEK");
        Assert.assertEquals("2023_04", partName);

        // 1. 2020-05-25, start day: MONDAY, offset 0
        property = new DynamicPartitionProperty(getDynamProp("WEEK", -3, 3, 1, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-25"), 0,
                FORMAT);
        Assert.assertEquals("2020-05-25", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "WEEK");
        Assert.assertEquals("2020_22", partName);

        // 2. 2020-05-28, start day: MONDAY, offset 0
        property = new DynamicPartitionProperty(getDynamProp("WEEK", -3, 3, 1, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-28"), 0,
                FORMAT);
        Assert.assertEquals("2020-05-25", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "WEEK");
        Assert.assertEquals("2020_22", partName);

        // 3. 2020-05-25, start day: SUNDAY, offset 0
        property = new DynamicPartitionProperty(getDynamProp("WEEK", -3, 3, 7, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-25"), 0,
                FORMAT);
        Assert.assertEquals("2020-05-24", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "WEEK");
        Assert.assertEquals("2020_22", partName);

        // 4. 2020-05-25, start day: MONDAY, offset -2
        property = new DynamicPartitionProperty(getDynamProp("WEEK", -3, 3, 1, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-25"), -2,
                FORMAT);
        Assert.assertEquals("2020-05-11", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "WEEK");
        Assert.assertEquals("2020_20", partName);

        // 5. 2020-02-29, start day: WED, offset 0
        property = new DynamicPartitionProperty(getDynamProp("WEEK", -3, 3, 3, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-02-29"), 0,
                FORMAT);
        Assert.assertEquals("2020-02-26", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "WEEK");
        Assert.assertEquals("2020_09", partName);

        // 6. 2020-02-29, start day: TUS, offset 1
        property = new DynamicPartitionProperty(getDynamProp("WEEK", -3, 3, 2, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-02-29"), 1,
                FORMAT);
        Assert.assertEquals("2020-03-03", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "WEEK");
        Assert.assertEquals("2020_10", partName);

        // 6. 2020-01-01, start day: MONDAY, offset -1
        property = new DynamicPartitionProperty(getDynamProp("WEEK", -3, 3, 1, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-01-01"), -1,
                FORMAT);
        Assert.assertEquals("2019-12-23", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "WEEK");
        Assert.assertEquals("2019_52", partName);

        // 6. 2020-01-01, start day: MONDAY, offset 0
        property = new DynamicPartitionProperty(getDynamProp("WEEK", -3, 3, 1, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-01-01"), 0,
                FORMAT);
        Assert.assertEquals("2019-12-30", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "WEEK");
        Assert.assertEquals("2019_53", partName);

        // TimeUnit: MONTH
        // 1. 2020-05-25, start day: 1, offset 0
        property = new DynamicPartitionProperty(getDynamProp("MONTH", -3, 3, -1, 1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-25"), 0,
                FORMAT);
        Assert.assertEquals("2020-05-01", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "MONTH");
        Assert.assertEquals("202005", partName);

        // 2. 2020-05-25, start day: 26, offset 0
        property = new DynamicPartitionProperty(getDynamProp("MONTH", -3, 3, -1, 26));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-25"), 0,
                FORMAT);
        Assert.assertEquals("2020-04-26", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "MONTH");
        Assert.assertEquals("202004", partName);

        // 3. 2020-05-25, start day: 26, offset -1
        property = new DynamicPartitionProperty(getDynamProp("MONTH", -3, 3, -1, 26));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-05-25"), -1,
                FORMAT);
        Assert.assertEquals("2020-03-26", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "MONTH");
        Assert.assertEquals("202003", partName);

        // 4. 2020-02-29, start day: 26, offset 3
        property = new DynamicPartitionProperty(getDynamProp("MONTH", -3, 3, -1, 26));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-02-29"), 3,
                FORMAT);
        Assert.assertEquals("2020-05-26", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "MONTH");
        Assert.assertEquals("202005", partName);

        // 5. 2020-02-29, start day: 27, offset 0
        property = new DynamicPartitionProperty(getDynamProp("MONTH", -3, 3, -1, 27));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-02-29"), 0,
                FORMAT);
        Assert.assertEquals("2020-02-27", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "MONTH");
        Assert.assertEquals("202002", partName);

        // 6. 2020-02-29, start day: 27, offset -3
        property = new DynamicPartitionProperty(getDynamProp("MONTH", -3, 3, -1, 27));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-02-29"), -3,
                FORMAT);
        Assert.assertEquals("2019-11-27", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "MONTH");
        Assert.assertEquals("201911", partName);

        // 7. 2020-02-29, offset -3
        property = new DynamicPartitionProperty(getDynamProp("YEAR", -3, 3, -1, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-02-29"), -3,
                FORMAT);
        Assert.assertEquals("2017-01-01", res);
        partName = DynamicPartitionUtil.getFormattedPartitionName(getCTSTimeZone(), res, "YEAR");
        Assert.assertEquals("2017", partName);

        property = new DynamicPartitionProperty(getDynamProp("MICROSECOND", -3, 3, -1, -1));
        res = DynamicPartitionUtil.getPartitionRangeString(property, getZonedDateTimeFromStr("2020-02-29"), -3,
                FORMAT);
        Assert.assertNull(res);
    }