From b99e8ac96520e6e53ca09d02990a14edd924952e Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 18 Apr 2022 15:08:54 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-69887=E3=80=90=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E4=B8=93=E9=A1=B9=E4=BC=98=E5=8C=96=E3=80=91?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=8E=A7=E4=BB=B6=E7=9A=84=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BAyyMMdd=E6=88=96yyMM=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=89=8D=E7=AB=AF=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../date/check/DateFormatFrontCheck.java | 3 +-- .../date/check/DateFormatFrontCheckTest.java | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 designer-form/src/test/java/com/fr/design/widget/ui/designer/date/check/DateFormatFrontCheckTest.java 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 791f079c6..165a900ad 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 000000000..d69728441 --- /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")); + } +}