diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/date/check/DateFormatFrontCheck.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/date/check/DateFormatFrontCheck.java index 791f079c68..165a900adc 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/date/check/DateFormatFrontCheck.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/date/check/DateFormatFrontCheck.java @@ -62,8 +62,7 @@ public class DateFormatFrontCheck implements DateFormatCheck { } private boolean isSpecialFmt(String fmt) { - String lowerFmt = fmt.toLowerCase(); - return AssistUtils.equals(lowerFmt, "%y%x") || AssistUtils.equals(lowerFmt, "%y%x%d"); + return AssistUtils.equals(fmt, "%Y%X") || AssistUtils.equals(fmt, "%Y%X%d"); } private String parseFmt(String fmt) { diff --git a/designer-form/src/test/java/com/fr/design/widget/ui/designer/date/check/DateFormatFrontCheckTest.java b/designer-form/src/test/java/com/fr/design/widget/ui/designer/date/check/DateFormatFrontCheckTest.java new file mode 100644 index 0000000000..d697284412 --- /dev/null +++ b/designer-form/src/test/java/com/fr/design/widget/ui/designer/date/check/DateFormatFrontCheckTest.java @@ -0,0 +1,27 @@ +package com.fr.design.widget.ui.designer.date.check; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2022/4/18 + */ +public class DateFormatFrontCheckTest { + + @Test + public void testAccept() { + Assert.assertTrue(DateFormatFrontCheck.KEY.accept("20220101", "yyyyMMdd")); + Assert.assertTrue(DateFormatFrontCheck.KEY.accept("202201", "yyyyMM")); + Assert.assertTrue(DateFormatFrontCheck.KEY.accept("2022-01-01", "yyyy-MM-dd")); + Assert.assertTrue(DateFormatFrontCheck.KEY.accept("22/01/01", "yy/MM/dd")); + Assert.assertTrue(DateFormatFrontCheck.KEY.accept("2022年01月01日", "yyyy年MM月dd日")); + Assert.assertTrue(DateFormatFrontCheck.KEY.accept("2022/01/01 12:30:00", "yyyy/MM/dd HH:mm:ss")); + + Assert.assertFalse(DateFormatFrontCheck.KEY.accept("220101", "yyMMdd")); + Assert.assertFalse(DateFormatFrontCheck.KEY.accept("20221", "yyyyM")); + Assert.assertFalse(DateFormatFrontCheck.KEY.accept("20220101123000", "yyyyMMddHHmmss")); + Assert.assertFalse(DateFormatFrontCheck.KEY.accept("2022-01-01", "YYYY-MM-dd")); + } +}