Here you can find the source of toFloat(Object ob, Float defaultFloat)
public static Float toFloat(Object ob, Float defaultFloat)
//package com.java2s; public class Main { public static Float toFloat(Object ob, Float defaultFloat) { if (ob == null) { return defaultFloat; }/*from w ww .j ava 2s. c o m*/ if (ob instanceof Integer) { return ((Integer) ob).floatValue(); } else if (ob instanceof Float) { return ((Float) ob).floatValue(); } else if (ob instanceof Double) { return ((Double) ob).floatValue(); } else if (ob instanceof Byte) { return ((Byte) ob).floatValue(); } else { try { return new Float(ob.toString()); } catch (Exception e) { return defaultFloat; } } } public static Float toFloat(Object ob) { return toFloat(ob, 0f); } }