0

I'd like to override the behavior of Java's Formatter to change it's behavior for handling nulls. Right now, whenever it encounters a null value, it inserts the string "null" in place for the format specifier. I'm trying to instead replace these with the string "NA".

It is insufficient for me to simply loop over my argument list and replace the nulls with "NA" strings, since it may be the case that the format specifier I encounter is incompatible with strings. For example, Java allows you to write something like String.format("%.3f", null), but not String.format("%.3f", "NA").

Is there any way to do this?

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.