[FINERACT-1965] Dateformat validation error message with the original dateformat
This commit is contained in:
committed by
Arnold Gálovics
parent
e7013309ca
commit
c9e9a5f546
+5
-4
@@ -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);
|
||||
|
||||
+2
-2
@@ -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"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user