|  | @ -20,30 +20,30 @@ public class IdCardUtil {
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public static String getSexForIdcard(String CardCode) throws Exception{
 | 
	
		
			
				|  |  |     public static String getSexForIdcard(String CardCode) throws Exception {
 | 
	
		
			
				|  |  |         String sex = Constant.level_sex_2;
 | 
	
		
			
				|  |  |             if (CardCode.length() == 18) {
 | 
	
		
			
				|  |  |                 if (Integer.parseInt(CardCode.substring(16).substring(0, 1)) % 2 == 0) {// 判断性别
 | 
	
		
			
				|  |  |                     // modifid by lyr 2016-09-29
 | 
	
		
			
				|  |  |                     // sex =  Constant.level_sex_2;
 | 
	
		
			
				|  |  |                     sex = Constant.level_sex_1;
 | 
	
		
			
				|  |  |                     // modifid by lyr 2016-09-29
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     // modifid by lyr 2016-09-29
 | 
	
		
			
				|  |  |                     // sex =  Constant.level_sex_1;
 | 
	
		
			
				|  |  |                     sex = Constant.level_sex_2;
 | 
	
		
			
				|  |  |                     // modifid by lyr 2016-09-29
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else if (CardCode.length() == 15) {
 | 
	
		
			
				|  |  |                 String usex = CardCode.substring(14, 15);// 用户的性别
 | 
	
		
			
				|  |  |                 if (Integer.parseInt(usex) % 2 == 0) {
 | 
	
		
			
				|  |  |                     // sex =  Constant.level_sex_2;
 | 
	
		
			
				|  |  |                     sex = Constant.level_sex_1;
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     // sex =  Constant.level_sex_1;
 | 
	
		
			
				|  |  |                     sex = Constant.level_sex_2;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |         if (CardCode.length() == 18) {
 | 
	
		
			
				|  |  |             if (Integer.parseInt(CardCode.substring(16).substring(0, 1)) % 2 == 0) {// 判断性别
 | 
	
		
			
				|  |  |                 // modifid by lyr 2016-09-29
 | 
	
		
			
				|  |  |                 // sex =  Constant.level_sex_2;
 | 
	
		
			
				|  |  |                 sex = Constant.level_sex_1;
 | 
	
		
			
				|  |  |                 // modifid by lyr 2016-09-29
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 // modifid by lyr 2016-09-29
 | 
	
		
			
				|  |  |                 // sex =  Constant.level_sex_1;
 | 
	
		
			
				|  |  |                 sex = Constant.level_sex_2;
 | 
	
		
			
				|  |  |                 // modifid by lyr 2016-09-29
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else if (CardCode.length() == 15) {
 | 
	
		
			
				|  |  |             String usex = CardCode.substring(14, 15);// 用户的性别
 | 
	
		
			
				|  |  |             if (Integer.parseInt(usex) % 2 == 0) {
 | 
	
		
			
				|  |  |                 // sex =  Constant.level_sex_2;
 | 
	
		
			
				|  |  |                 sex = Constant.level_sex_1;
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 // sex =  Constant.level_sex_1;
 | 
	
		
			
				|  |  |                 sex = Constant.level_sex_2;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return sex;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -94,33 +94,36 @@ public class IdCardUtil {
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public static int getAgeForIdcard(String idcard) {
 | 
	
		
			
				|  |  |         int age = 0;
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             int age = 0;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (org.springframework.util.StringUtils.isEmpty(idcard)) {
 | 
	
		
			
				|  |  |             return age;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |             if (org.springframework.util.StringUtils.isEmpty(idcard)) {
 | 
	
		
			
				|  |  |                 return age;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String birth = "";
 | 
	
		
			
				|  |  |             String birth = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (idcard.length() == 18) {
 | 
	
		
			
				|  |  |             birth = idcard.substring(6, 14);
 | 
	
		
			
				|  |  |         } else if (idcard.length() == 15) {
 | 
	
		
			
				|  |  |             birth = "19" + idcard.substring(6, 12);
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             return 0;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |             if (idcard.length() == 18) {
 | 
	
		
			
				|  |  |                 birth = idcard.substring(6, 14);
 | 
	
		
			
				|  |  |             } else if (idcard.length() == 15) {
 | 
	
		
			
				|  |  |                 birth = "19" + idcard.substring(6, 12);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 return 0;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         int year = Integer.valueOf(birth.substring(0, 4));
 | 
	
		
			
				|  |  |         int month = Integer.valueOf(birth.substring(4, 6));
 | 
	
		
			
				|  |  |         int day = Integer.valueOf(birth.substring(6));
 | 
	
		
			
				|  |  |         Calendar cal = Calendar.getInstance();
 | 
	
		
			
				|  |  |         age = cal.get(Calendar.YEAR) - year;
 | 
	
		
			
				|  |  |         //周岁计算
 | 
	
		
			
				|  |  |         if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) {
 | 
	
		
			
				|  |  |             age--;
 | 
	
		
			
				|  |  |             int year = Integer.valueOf(birth.substring(0, 4));
 | 
	
		
			
				|  |  |             int month = Integer.valueOf(birth.substring(4, 6));
 | 
	
		
			
				|  |  |             int day = Integer.valueOf(birth.substring(6));
 | 
	
		
			
				|  |  |             Calendar cal = Calendar.getInstance();
 | 
	
		
			
				|  |  |             age = cal.get(Calendar.YEAR) - year;
 | 
	
		
			
				|  |  |             //周岁计算
 | 
	
		
			
				|  |  |             if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) {
 | 
	
		
			
				|  |  |                 age--;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return age;
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return 0;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return age;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 |