首页 > 学院 > 开发设计 > 正文

java判断该手机号码是否是移动手机号段

2019-11-17 04:15:25
字体:
来源:转载
供稿:网友

 /**
     * 判断该手机号码是否是移动手机号段<br>
     *
     * @param phone
     * @return true or false
     * @throws Exception
     */
    PRivate boolean isMobileNumber(String phone) throws ServiceException {
        boolean isExist = false;

        phone = phone.trim();
        if (phone == null || phone.length() < 7) {
            try {
                throw new Exception("wrong phone length");
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        String code = phone.substring(0, 7);// 暂时保留2009-01-16 16:30

        if (code.startsWith("134") || code.startsWith("135")
                || code.startsWith("136") || code.startsWith("137")
                || code.startsWith("138") || code.startsWith("139")
                || code.startsWith("159") || code.startsWith("158")
                || code.startsWith("150") || code.startsWith("157")
                || code.startsWith("151") || code.startsWith("188")
                || code.startsWith("189")) {
            isExist = true;
        }
        return isExist;

    }


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表