Java tutorial
//package com.java2s; public class Main { public static float convertTofloat(String fStr, float defValue) { try { return Float.parseFloat(fStr); } catch (NumberFormatException e) { } return defValue; } public static Float convertToFloat(String fStr) { try { return Float.parseFloat(fStr); } catch (NumberFormatException e) { } return null; } }