Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.telephony.PhoneNumberUtils;

public class Main {
    /**
     * "Flattens" a phone number into a standard format by eliminating all symbols, etc.
     */
    public static String flattenPhone(String formattedPhone) {
        String flattened = PhoneNumberUtils.stripSeparators(formattedPhone);
        flattened = flattened.replaceAll("\\+", "");
        if (flattened.charAt(0) == '1')
            flattened = flattened.replaceFirst("1", "");
        return flattened;
    }
}