Here you can find the source of convertBoolean(Object value, int srcType, int destType)
public static Object convertBoolean(Object value, int srcType, int destType) throws Exception
//package com.java2s; //License from project: Open Source License public class Main { public static Object convertBoolean(Object value, int srcType, int destType) throws Exception { // is same source/destination then return value // * commented to allow cloneObject to allow clone creation // if (srcType == destType) { // return value; // }/*from w ww .j a va2 s . c om*/ if ((isNumeric(destType) == true) || ((isString(destType) == false) && (isBoolean(destType) == false))) { throw new Exception("boolean conversion failed. (" + value.toString().trim() + "/" + srcType + ":" + destType + ")"); } try { switch (destType) { case java.sql.Types.BIT: Integer i = new Integer(value.toString().trim()); return i.equals(new Integer((int) 0)) ? new Boolean(false) : new Boolean(true); case java.sql.Types.BOOLEAN: return new Boolean(value.toString().trim()); default: throw new Exception("boolean conversion failed. (" + value.toString().trim() + "/" + srcType + ":" + destType + ")"); } } catch (NumberFormatException ex) { throw new Exception("boolean conversion failed. (" + value.toString().trim() + "/" + srcType + ":" + destType + ")"); } } public static boolean isNumeric(int dataType) { switch (dataType) { case java.sql.Types.NUMERIC: case java.sql.Types.DECIMAL: case java.sql.Types.BIT: case java.sql.Types.TINYINT: case java.sql.Types.SMALLINT: case java.sql.Types.INTEGER: case java.sql.Types.BIGINT: case java.sql.Types.REAL: case java.sql.Types.DOUBLE: case java.sql.Types.FLOAT: return true; default: return false; } } public static boolean isString(int dataType) { switch (dataType) { case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: case java.sql.Types.NCHAR: case java.sql.Types.NVARCHAR: case java.sql.Types.LONGNVARCHAR: return true; default: return false; } } public static boolean isBoolean(int dataType) { switch (dataType) { case java.sql.Types.BIT: case java.sql.Types.BOOLEAN: return true; default: return false; } } }