Boolean to String


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);

Date Gettime

Useless throwing Exceptions