Here you can find the source of toBoolean(Object obj)
public static boolean toBoolean(Object obj) throws Exception
//package com.java2s; public class Main { public static boolean toBoolean(Object obj) throws Exception { return Boolean.valueOf(toString(obj).trim()).booleanValue(); }/* ww w . j a v a 2 s. c o m*/ public static boolean toBoolean(Object obj, boolean defaultValue) { try { return toBoolean(obj); } catch (Exception ex) { return defaultValue; } } public static String toString(double obj) throws Exception { return Double.toString(obj); } public static String toString(double obj, String defaultValue) { try { return toString(obj); } catch (Exception ex) { return defaultValue; } } public static String toString(int obj) throws Exception { return Integer.toString(obj); } public static String toString(int obj, String defaultValue) { try { return toString(obj); } catch (Exception ex) { return defaultValue; } } public static String toString(long obj) throws Exception { return Long.toString(obj); } public static String toString(long obj, String defaultValue) { try { return toString(obj); } catch (Exception ex) { return defaultValue; } } public static String toString(Object obj) throws Exception { if (obj == null) { return ""; } return String.valueOf(obj); } public static String toString(Object obj, String defaultValue) { try { return toString(obj); } catch (Exception ex) { return defaultValue; } } }