Java Utililty Methods String to Boolean

List of utility methods to do String to Boolean

Description

The list of methods to do String to Boolean are organized into topic(s).

Method

BooleanasBoolean(String flag)
Converts the given string into a Boolean flag of either true, false or null.
return flag == null ? null : flag.equals(YES_AS_STRING);
StringasBoolean(String name, boolean value)
as Boolean
return "{\"" + name + "\" : " + value + "}";
BooleanasBoolean(String s)
as Boolean
if (s.equalsIgnoreCase("true")) {
    return Boolean.TRUE;
} else if (s.equalsIgnoreCase("false")) {
    return Boolean.FALSE;
} else {
    return null;
booleanasBoolean(String str)
as Boolean
if (str == null || str.length() == 0)
    return false;
str = str.trim();
if ("1".equals(str))
    return true;
str = str.toLowerCase();
return "true".equals(str) || "yes".equals(str) || "y".equals(str) || "on".equals(str) || "ja".equals(str)
        || "enable".equals(str);
...
BooleanasBoolean(String string)
Converts string to boolean
return (string == null) ? null : Boolean.valueOf(string);
booleanasBoolean(String value)
as Boolean
return asBoolean(value, false);
booleanasBoolean(String value, boolean defaultValue)
as Boolean
return value == null ? defaultValue : Boolean.valueOf(value.trim()).booleanValue();
booleanatob(final String str, final boolean def)
atob
try {
    return Boolean.parseBoolean(str);
} catch (final Exception ex) {
    ex.printStackTrace();
return def;
booleanatob(String pString_)
Converts a String to a boolean.
return (Boolean.valueOf(pString_).booleanValue());
booleanatob(String s)
atob
if (s == null || s.length() < 1)
    throw new IllegalArgumentException("Cannot convert empty string to boolean");
s = s.toLowerCase().trim();
if (s.equals("true"))
    return true;
if (s.equals("false"))
    return false;
if (s.equals("1"))
...