Java Boolean From toBoolean(String value)

Here you can find the source of toBoolean(String value)

Description

to Boolean

License

Open Source License

Declaration

public static Boolean toBoolean(String value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static Boolean toBoolean(String value) {
        if (null == value) {
            return null;
        }//from  w w w. j  av  a  2  s .  co  m
        String str = value.trim();
        if ("null".equals(str)) {
            return null;
        }
        if ("1".equals(str)) {
            return true;
        }
        if ("0".equals(str)) {
            return false;
        }
        return Boolean.parseBoolean(str);
    }

    public static Boolean toBoolean(Object value) {
        if (null == value) {
            return null;
        }
        return toBoolean(String.valueOf(value));
    }
}

Related

  1. toBoolean(String value)
  2. toBoolean(String value)
  3. toBoolean(String value)
  4. toBoolean(String value)
  5. toBoolean(String value)
  6. toBoolean(String value, boolean _default)
  7. toBoolean(String value, boolean dEfault)
  8. toBoolean(String value, boolean defaultValue)
  9. toBoolean(String value, boolean defaultValue)