This is an automated email from the ASF dual-hosted git repository.
arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new c9e9a5f54 [FINERACT-1965] Dateformat validation error message with the
original dateformat
c9e9a5f54 is described below
commit c9e9a5f546c202cc9484c366ee0bc964c58cc764
Author: taskain7 <[email protected]>
AuthorDate: Tue Aug 29 14:02:46 2023 +0200
[FINERACT-1965] Dateformat validation error message with the original
dateformat
---
.../infrastructure/core/serialization/JsonParserHelper.java | 9 +++++----
.../org/apache/fineract/integrationtests/DateValidationTest.java | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git
a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/serialization/JsonParserHelper.java
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/serialization/JsonParserHelper.java
index da47385bc..0074442ef 100644
---
a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/serialization/JsonParserHelper.java
+++
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/serialization/JsonParserHelper.java
@@ -473,11 +473,12 @@ public class JsonParserHelper {
parametersPassedInCommand.add(parameterName);
try {
- timeFormat = timeFormat.replace("y", "u");
+ String strictResolveCompatibleTimeFormat =
timeFormat.replace("y", "u");
final JsonPrimitive primitive =
object.get(parameterName).getAsJsonPrimitive();
timeValueAsString = primitive.getAsString();
DateTimeFormatter timeFormatter = new
DateTimeFormatterBuilder().parseCaseInsensitive().parseLenient()
-
.appendPattern(timeFormat).toFormatter(clientApplicationLocale).withResolverStyle(ResolverStyle.STRICT);
+
.appendPattern(strictResolveCompatibleTimeFormat).toFormatter(clientApplicationLocale)
+ .withResolverStyle(ResolverStyle.STRICT);
if (StringUtils.isNotBlank(timeValueAsString)) {
value = LocalDateTime.parse(timeValueAsString,
timeFormatter);
}
@@ -540,9 +541,9 @@ public class JsonParserHelper {
LocalDateTime eventLocalDateTime = null;
if (StringUtils.isNotBlank(dateTimeAsString)) {
try {
- dateTimeFormat = dateTimeFormat.replace("y", "u");
+ String strictResolveCompatibleDateTimeFormat =
dateTimeFormat.replace("y", "u");
DateTimeFormatter formatter = new
DateTimeFormatterBuilder().parseCaseInsensitive().parseLenient()
-
.appendPattern(dateTimeFormat).optionalStart().appendPattern("
HH:mm:ss").optionalEnd()
+
.appendPattern(strictResolveCompatibleDateTimeFormat).optionalStart().appendPattern("
HH:mm:ss").optionalEnd()
.parseDefaulting(ChronoField.HOUR_OF_DAY,
0).parseDefaulting(ChronoField.MINUTE_OF_HOUR, 0)
.parseDefaulting(ChronoField.SECOND_OF_MINUTE,
0).toFormatter(clientApplicationLocale)
.withResolverStyle(ResolverStyle.STRICT);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DateValidationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DateValidationTest.java
index 57a5270fd..b8caed189 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DateValidationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DateValidationTest.java
@@ -119,7 +119,7 @@ public class DateValidationTest {
HashMap<String, Object> error = errors.get(0);
assertNotNull(error);
assertEquals(
- "The parameter `expectedDisbursementDate` is invalid based on
the dateFormat: `dd MMMM uuuu` and locale: `en_GB` provided:",
+ "The parameter `expectedDisbursementDate` is invalid based on
the dateFormat: `dd MMMM yyyy` and locale: `en_GB` provided:",
error.get("developerMessage"));
}
@@ -134,7 +134,7 @@ public class DateValidationTest {
assertNotNull(errors);
Map<String, Object> error = errors.get(0);
assertNotNull(error);
- assertEquals("The parameter `expiration` is invalid based on the
dateFormat: `dd MMMM uuuu HH:mm:ss` and locale: `en` provided:",
+ assertEquals("The parameter `expiration` is invalid based on the
dateFormat: `dd MMMM yyyy HH:mm:ss` and locale: `en` provided:",
error.get("developerMessage"));
}