Java tutorial
//package com.java2s; import java.util.regex.Pattern; public class Main { public static float parseFloat(String str) { if (!"".equals(str) && !"null".equals(str) && str != null && isNumeric(str)) { return Float.parseFloat(str); } else { return (float) 0.0; } } public static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[0-9]*"); return pattern.matcher(str).matches(); } }