I'm trying to parse a String Date like this: 2021-03-19T13:08:32.58600
with BeanIO in my template:
<field name="updatedAt" typeHandler="dateTypeHandler" format="yyyy-MM-dd'T'HH:mm:SSSXX"/>
And I'm getting Invalid date
error.
I test some cases with SimpleDateFormat and for example, if I do something like this:
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(text)
it works.
The problem is in DateTypeHandlerSupport
class, the method parse validate the length:
protected Date parseDate(String text) throws TypeConversionException {
if ("".equals(text))
return null;
ParsePosition pp = new ParsePosition(0);
Date date = getFormat().parse(text, pp);
if (pp.getErrorIndex() >= 0 || pp.getIndex() != text.length()) {
throw new TypeConversionException("Invalid date");
}
return date;
}
Is there any way which I could parse the string without creating my own DateTypeHandler?