I am using the CustomDateEditor to convert the date from flat file. The flat file contains the date in ddmmyy format. The record is converted to Bean which is JPA entity.
I want to catch the Exception if the date is invalid in validation Processor.Code:<bean id="myFieldSetMapper" class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper"> <property name="targetType" value="domain.MyClass" /> <property name="customEditors"> <map> <entry key="org.springframework.batch.item.file.transform.Range[]"> <bean class="org.springframework.batch.item.file.transform.RangeArrayPropertyEditor" /> </entry> <entry key="java.util.Date"> <bean class="org.springframework.beans.propertyeditors.CustomDateEditor"> <constructor-arg> <bean class="java.text.SimpleDateFormat"> <constructor-arg value="ddMMyy" /> </bean> </constructor-arg> <constructor-arg value="false" /> </bean> </entry> </map> </property> </bean>
The codes are running fine. But when the invalid date occurs, it converted to some arbitrary date and no exception thrown. for example if the String passed to the date field is 351308 in ddmmyy format, it is converting to '04-feb-2009' instead of throwing the exception.
Please suggest how to correct the problem. I am using spring 3.1.1 and spring batch 2.1.8.
Thanks


Reply With Quote