You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					
					
						
							74 lines
						
					
					
						
							2.5 KiB
						
					
					
				
			
		
		
	
	
							74 lines
						
					
					
						
							2.5 KiB
						
					
					
				| package com.ynxbd.common.helper.common;
 | |
| 
 | |
| import org.apache.commons.lang3.ObjectUtils;
 | |
| import java.util.Arrays;
 | |
| import java.util.List;
 | |
| 
 | |
| public class ValidHelper {
 | |
| 
 | |
|     private static final List<String> NATIONS = Arrays.asList("汉族", "哈尼族", "彝族", "回族", "苗族", "壮族", "傣族", "白族", "藏族", "蒙古族", "维吾尔族", "布依族", "朝鲜族", "满族",
 | |
|             "侗族", "瑶族", "土家族", "哈萨克族", "黎族", "傈僳族", "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族",
 | |
|             "柯尔克孜族", "土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族", "阿昌族", "普米族",
 | |
|             "塔吉克族", "怒族", "乌孜别克族", "俄罗斯族", "鄂温克族", "德昂族", "保安族", "裕固族", "京族", "塔塔尔族", "独龙族",
 | |
|             "鄂伦春族", "赫哲族", "门巴族", "珞巴族", "基诺族", "穿青人");
 | |
| 
 | |
|     /**
 | |
|      * 是否存在民族
 | |
|      *
 | |
|      * @return 是否存在
 | |
|      */
 | |
|     public static boolean isValidNation(String nation) {
 | |
|         if (ObjectUtils.isEmpty(nation)) {
 | |
|             return false;
 | |
|         }
 | |
|         if (nation.equals("穿青人")) {
 | |
|             return true;
 | |
|         }
 | |
|         if (!nation.contains("族")) {
 | |
|             nation += "族";
 | |
|         }
 | |
|         return NATIONS.contains(nation);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * 电话号码是否合法
 | |
|      *
 | |
|      * @param tel 电话号码
 | |
|      * @return 是否合法
 | |
|      */
 | |
|     public static boolean isValidTel(String tel) {
 | |
|         if (ObjectUtils.isEmpty(tel)) {
 | |
|             return false;
 | |
|         }
 | |
|         if (tel.length() != 11) {
 | |
|             return tel.length() == 7;
 | |
|         }
 | |
|         return true;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * 身份证是否合法
 | |
|      *
 | |
|      * @param idCard 身份证号
 | |
|      * @return 是否合法
 | |
|      */
 | |
|     public static boolean isValidIdCard(String idCard) {
 | |
|         if (ObjectUtils.isEmpty(idCard)) {
 | |
|             return false;
 | |
|         }
 | |
| 
 | |
|         if (idCard.length() != 18) {
 | |
|             return idCard.length() == 15;
 | |
|         }
 | |
|         return true;
 | |
|     }
 | |
| 
 | |
|     public static void main(String[] args) {
 | |
|         long begTime = System.currentTimeMillis();//记录开始时间
 | |
| 
 | |
|         long endTime = System.currentTimeMillis();// 记录结束时间
 | |
| 
 | |
|         long down = endTime - begTime;
 | |
|         System.out.println("执行时间:" + down / 1000 + "s(" + down + "ms)");
 | |
|     }
 | |
| }
 | |
| 
 |