Here you can find the source of toFloat(Object obj)
public static float toFloat(Object obj)
//package com.java2s; //License from project: Open Source License public class Main { public static float toFloat(Object obj) { return toFloat(obj, 0); }// ww w .j av a2 s . c om public static float toFloat(Object obj, float defaultValue) { if (obj == null) { return defaultValue; } if (obj instanceof Number) { Number number = (Number) obj; return number.floatValue(); } String value = toString(obj); try { return Float.parseFloat(value); } catch (Exception e) { } return defaultValue; } public static String toString(Object value) { if (value == null) { return ""; } return value.toString().trim(); } }