Here you can find the source of toBoolean(Object val, boolean defValue)
public static boolean toBoolean(Object val, boolean defValue)
//package com.java2s; //License from project: LGPL public class Main { public static boolean toBoolean(Object val, boolean defValue) { if (val != null) { String value = String.valueOf(val); try { return Boolean.valueOf(value) || toInt(val, 0) == 1; } catch (Exception e) { }/*w w w.ja v a 2 s .com*/ } return defValue; } public static int toInt(Object num, int defValue) { if (num != null) { String value = String.valueOf(num); try { return Integer.parseInt(value); } catch (Exception e) { } } return defValue; } }