allow empty string as date value nil

This commit is contained in:
Peter Hormanns 2021-10-27 21:18:46 +02:00
parent 0f6b43605d
commit 81d34d4e19

View File

@ -27,11 +27,14 @@ public class DefaultDateParameterMapMapper implements ParameterMapMapper<Date> {
if (value instanceof Date) { if (value instanceof Date) {
return (Date) value; return (Date) value;
} }
if (value instanceof String && ((String) value).trim().length() == 0) { if (value instanceof String) {
final String valueAsString = ((String) value).trim();
if (valueAsString.length() > 0) {
try { try {
return DateUtil.DEFAULT_DATEFORMAT.parse((String) value); return DateUtil.DEFAULT_DATEFORMAT.parse(valueAsString);
} catch (ParseException e) { } catch (ParseException e) {
throw new UserException(new UserError(UserError.MSG_INVALID_DATEFORMAT, propertyName, (String) value)); throw new UserException(new UserError(UserError.MSG_INVALID_DATEFORMAT, propertyName, valueAsString));
}
} }
} }
return null; return null;