Java tutorial
//package com.java2s; // Released under the Apache License, Version 2.0 import java.util.Locale; import android.telephony.PhoneNumberUtils; public class Main { /** * Format a phone number based on the number's country code, falling * back to the format defined by the user's current locale. This is * to replace calling {@link PhoneNumberUtils#formatNumber(String)}, * which was deprecated in the LOLLIPOP release. * * @see PhoneNumberUtils#formatNumber(String, String) * @param number The phone number to be formatted * @return The phone number, formatted based on the country code or * user's locale. */ public static String formatNumber(String number) { return PhoneNumberUtils.formatNumber(number, Locale.getDefault().getCountry()); } }