Is Valid Phone Number by length - Android Phone

Android examples for Phone:Phone Number

Description

Is Valid Phone Number by length

Demo Code


//package com.java2s;

public class Main {
    public static boolean IsValidPhoneNumber(String phoneNumber) {
        // validating for length
        if (phoneNumber.length() != 10)
            return false;

        // validating for numeric
        try {//ww  w.ja v a2s. com
            Long.parseLong(phoneNumber);
        } catch (Exception e) {
            return false;
        }

        return true;
    }
}

Related Tutorials