Here you can find the source of toFloat(Object value)
public static Float toFloat(Object value)
//package com.java2s; //License from project: Apache License public class Main { /**//from w w w . j av a 2 s .co m * Convert an Object to a Float. */ public static Float toFloat(Object value) { if (value == null) return null; if (value instanceof Float) return (Float) value; if (value instanceof String) { if ("".equals((String) value)) return null; return new Float((String) value); } if (value instanceof Number) return new Float(((Number) value).floatValue()); return new Float(value.toString()); } /** * Convert an Object to a float, or 0 if it is null. */ public static float floatValue(Object value) { if (value == null) return 0.0f; return toFloat(value).floatValue(); } }