Here you can find the source of parseFloat(String value)
public static float parseFloat(String value)
//package com.java2s; import java.math.BigDecimal; public class Main { public static float parseFloat(String value) { float result = (float) 0.00; if (value.length() > 0) { try { result = round(Float.parseFloat(value), 1); } catch (Exception e) { return (float) 0.00; }//from w w w . j ava 2s . c o m } return result; } public static float round(float d, int decimalPlace) { BigDecimal bd = new BigDecimal(Float.toString(d)); bd = bd.setScale(decimalPlace, BigDecimal.ROUND_FLOOR); return bd.floatValue(); } }