torchy (11) [Avatar] Offline
Congratulations on the book, it is very helpful.

I am looking for some advice about DefaultJobParametersConverter, which I have just read about: its implementation seems a bit average in these respects
1) the date format is hard coded to be 'yyyy/MM/dd'
2) there is no type for time, which I would think is quite commonly needed
3) there is no way to extend it with your own types

I am rewriting a batch job in spring batch to run from control-m: it passes in dates with a different format and I don't want to have to get that changed, and it passes in times.

Is there any way I can inject into CommandLineJobRunner my own implementation of JobParametersConverter?
arnaud.cogoluegnes (73) [Avatar] Offline
Re: DefaultJobParametersConverter
Hi, Torchy.

as soon you a declare a JobParametersConverter bean in the application context, Spring Batch will use it. That's the way to customize the date format for example.

there's no type for time indeed, the closest would be "long" then (remember that Date in Java works up to seconds, so perhaps it suits your needs, just check Spring Batch stores up to seconds in the batch metadata).

thanks for your interest in the book!
torchy (11) [Avatar] Offline
Re: DefaultJobParametersConverter

Sound advice.

Another question, completely unrelated. Is there an easy way to capture the exceptions thrown when an attempt is made to rerun a job that has already completed, and when an invalid parameter is supplied.

In both cases there is nothing in the Job Execution history, and I need to log something meaningful.

arnaud.cogoluegnes (73) [Avatar] Offline
Re: DefaultJobParametersConverter
this kind of logging must be done at the launching system level. You'll need to customize the CommandLineJobRunner to do so.

Perhaps an alternative: I'm pretty sure Spring Batch does some logging there, so an appropriate logging configuration could prevent some customization.