/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.common.utils;

import java.util.regex.Pattern;

/**
 * @author 田平 create 2016年12月12日下午5:46:49
 */
public class NumberUtil {
	public static final Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
	public static final Pattern mobile = Pattern.compile("^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$");
	public static final Pattern postalCode = Pattern.compile("^[1-9]\\d{5}$");

	public static boolean isNumber(String str) {
		return pattern.matcher(str).matches();
	}

	public static void main(String[] args) {
		System.out.println(isNumber("aaa"));
		System.out.println(isNumber("13"));
		System.out.println(isPostalCode("401120"));
	}

	//是否是移动电话号码
	public static boolean isMobile(String str) {
		return  mobile.matcher(str).matches();
	}

	//是否是邮政编码
	public static boolean isPostalCode(String str) {
		return postalCode.matcher(str).matches();
	}
}
