Java tutorial
//package com.java2s; //License from project: Apache License import android.util.Log; public class Main { public static double str2num(String s, double defVal) { if (s.equals("N/A")) return defVal; try { s = s.trim(); s = s.contains(" ") ? s.split(" ")[0] : s; return Double.parseDouble(s); } catch (Exception err) { Log.e("str2num", s, err); return defVal; } } }