Java tutorial
//package com.java2s; import android.text.TextUtils; public class Main { /** * Remove none digital character from the decimal string that maybe contains * none digit character. * * @param decimal * the decimal string. * @return the new digital string only contains digital character. */ public static String getPlain(String decimal) { if (TextUtils.isEmpty(decimal)) { decimal = "0"; } char[] ch = new char[decimal.length()]; int index = 0; for (int i = 0; i < decimal.length(); i++) { if (Character.isDigit(decimal.charAt(i))) { ch[index++] = decimal.charAt(i); } } return String.copyValueOf(ch, 0, index); } }