Android examples for java.lang:String Parse
Parse number string to float.
//package com.java2s; import android.text.TextUtils; public class Main { /**//from w w w .j a va2s . co m * Parse number string to float. * * @param num the float number string * @return float number */ public static float parseFloat(String num) { if (TextUtils.isEmpty(num) || TextUtils.isEmpty(num.trim())) { return 0f; } try { return Float.parseFloat(num); } catch (NumberFormatException e) { return 0f; } } }