Here you can find the source of toBoolean(Object obj)
public static boolean toBoolean(Object obj)
//package com.java2s; //License from project: Open Source License public class Main { public static boolean toBoolean(Object obj) { return toBoolean(obj, false); }/*from w w w .j av a 2 s. co m*/ public static boolean toBoolean(Object obj, boolean defaultValue) { if (obj == null) { return defaultValue; } try { return Boolean.parseBoolean(toString(obj)); } catch (Exception e) { } return defaultValue; } public static String toString(Object value) { if (value == null) { return ""; } return value.toString().trim(); } }