Java tutorial
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; import java.util.Locale; import android.util.Log; public class Main { public static int str2int(String s, int defVal) { if (s.equals("N/A")) return defVal; try { s = s.trim(); s = s.contains(" ") ? s.split(" ")[0] : s; return NumberFormat.getInstance(Locale.ENGLISH).parse(s).intValue(); } catch (Exception err) { Log.e("str2int", s, err); return defVal; } } }