This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
new b9b89ed212 NIFI-13557 Corrected Date Time Matcher to support single
digit months
b9b89ed212 is described below
commit b9b89ed212716d36f72fb82da9f13c67089f9af2
Author: dan-s1 <[email protected]>
AuthorDate: Fri Jul 19 13:34:26 2024 +0000
NIFI-13557 Corrected Date Time Matcher to support single digit months
This closes #9094
(cherry picked from commit 059a3b774521bb4f714748784c694c898018ae97)
Signed-off-by: David Handermann <[email protected]>
---
.../src/main/java/org/apache/nifi/util/text/RegexDateTimeMatcher.java | 2 +-
.../test/java/org/apache/nifi/util/text/TestRegexDateTimeMatcher.java | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git
a/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/text/RegexDateTimeMatcher.java
b/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/text/RegexDateTimeMatcher.java
index 48f0774493..b912c888e9 100644
---
a/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/text/RegexDateTimeMatcher.java
+++
b/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/text/RegexDateTimeMatcher.java
@@ -384,7 +384,7 @@ public class RegexDateTimeMatcher implements
DateTimeMatcher {
}
private void addShortMonth() {
- patterns.add("(?:0[1-9]|1[0-2])");
+ patterns.add("(?:0?[1-9]|1[0-2])");
range = range.plus(1, 2);
}
diff --git
a/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/text/TestRegexDateTimeMatcher.java
b/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/text/TestRegexDateTimeMatcher.java
index aadc98b07c..f6d84d7e2b 100644
---
a/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/text/TestRegexDateTimeMatcher.java
+++
b/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/text/TestRegexDateTimeMatcher.java
@@ -34,6 +34,8 @@ public class TestRegexDateTimeMatcher {
exampleToPattern.put("2018/12/12", "yyyy/MM/dd");
exampleToPattern.put("12/12/2018", "MM/dd/yyyy");
exampleToPattern.put("12/12/18", "MM/dd/yy");
+ exampleToPattern.put("1/1/18", "M/d/yy");
+ exampleToPattern.put("1/10/18", "M/d/yy");
exampleToPattern.put("1:40:55", "HH:mm:ss");
exampleToPattern.put("01:0:5", "HH:mm:ss");
exampleToPattern.put("12/12/2018 13:04:08 GMT-05:00", "MM/dd/yyyy
HH:mm:ss z");