Boolean to String

2020-02-03

Long time ago I’ve found this little gem:

if( value.equalsIgnoreCase(String.valueOf(Boolean.TRUE)) )
    return Boolean.TRUE.booleanValue();
else if( value.equalsIgnoreCase(String.valueOf(Boolean.FALSE)) )
    return Boolean.FALSE.booleanValue();

Interestingly the rest of the code made it impossible to:

  • enter with value = null
  • enter with mixed cased like tRuE

Therefore the code is effectively this:

return Boolean.parseBoolean(value);
code-funjava

Date Gettime

Useless throwing Exceptions