Here you can find the source of format(String number)
public static String format(String number)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010-2016 ITER Organization. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ public class Main { public static String format(String number) { StringBuilder cleanedNumber = new StringBuilder(); for (int index = 0; index < number.length(); index++) { char c = number.charAt(index); if (c == '+' || c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9') cleanedNumber.append(c); }/* ww w .j a va 2 s .c o m*/ return cleanedNumber.toString(); } }