Here you can find the source of formatPhoneNumber(String number)
Parameter | Description |
---|---|
number | a parameter |
public static String formatPhoneNumber(String number)
//package com.java2s; public class Main { /**/* w w w . j av a2s . c om*/ * Formats a number stripping it from any non digit except for a leading plus sign * @param number * @return */ public static String formatPhoneNumber(String number) { if (number != null) { String strippedNumber = number.replaceAll("\\D", ""); if (number.startsWith("+")) { return "+" + strippedNumber; } else { return strippedNumber; } } return null; } }