I want to add a boolean type parameter to spring JobParameters. But here: http://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/core/JobParameter.ParameterType.html it says JobParameter type accepts only Date, Double, Long, String.
How can I add a boolean or any custom object to JobParameters?
Only way to do it is to use some of supported types. You can, as @lucabassoricci suggested, use long or you can use String and do conversion back and forth. You are controlling both setting and reading of parameters so this is not that bad, you will always get either "true" or "false" string and you can do parse:
Boolean boolean1 = Boolean.valueOf("true");
boolean boolean2 = Boolean.parseBoolean("true");
As for setting parameter you can do:
Boolean.toString(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With