Android examples for java.lang:String Parse
Remove none digital character from the decimal string that maybe contains none digit character.
//package com.java2s; import android.text.TextUtils; public class Main { /**//w ww.ja v a 2 s . c o m * 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); } }