Android examples for java.lang:String Parse
parse value to int
//package com.java2s; import android.text.TextUtils; public class Main { /**//from w ww . java 2 s .c o m * parse value to int */ public static int toInt(Object value) { if (value instanceof Number) { return ((Number) value).intValue(); } return value == null ? 0 : toInt(String.valueOf(value)); } /** * parse value to int */ public static int toInt(String value) { return TextUtils.isEmpty(value) ? 0 : Integer.parseInt(value); } }