public static float parseFloat ( String val , float defVal ) { if ( TextUtils . isEmpty ( val ) ) return defVal ; try { return Float . parseFloat ( val ) ; } catch ( NumberFormatException e ) { return defVal ; } }
Parse a float from a String in a safe manner .