Java身份证处理工具

身份证处理工具

  1 /**
  2  * <html>
  3  * <body>
  4  *  <P> Copyright 1994 JsonInternational</p>
  5  *  <p> All rights reserved.</p>
  6  *  <p> Created on 19941115</p>
  7  *  <p> Created by Jason</p>
  8  *  </body>
  9  * </html>
 10  */
 11 package cn.ucaner.alpaca.framework.utils.card;
 12 
 13 import java.text.ParseException;
 14 import java.text.SimpleDateFormat;
 15 import java.util.Calendar;
 16 import java.util.Date;
 17 import java.util.HashMap;
 18 import java.util.Map;
 19 
 20 import cn.ucaner.alpaca.framework.utils.string.StringHelper;
 21 
 22 /**
 23 * @Package:cn.ucaner.framework.utils   
 24 * @ClassName:IdCardUtils   
 25 * @Description:   <p> 身份证工具类 </p>
 26 * @Author: - Jason 
 27 * @CreatTime:2017年8月30日 下午2:13:10   
 28 * @Modify By:   
 29 * @ModifyTime:  
 30 * @Modify marker:   
 31 * @version    V1.0
 32  */
 33 public class IdCardUtils extends StringHelper {
 34     
 35     /** 中国公民身份证号码最小长度。 */
 36     public static final int CHINA_ID_MIN_LENGTH = 15;
 37 
 38     /** 中国公民身份证号码最大长度。 */
 39     public static final int CHINA_ID_MAX_LENGTH = 18;
 40 
 41     /** 省、直辖市代码表 */
 42     public static final String[] cityCode = { "11",
 43             "12",
 44             "13",
 45             "14",
 46             "15",
 47             "21",
 48             "22",
 49             "23",
 50             "31",
 51             "32",
 52             "33",
 53             "34",
 54             "35",
 55             "36",
 56             "37",
 57             "41",
 58             "42",
 59             "43",
 60             "44",
 61             "45",
 62             "46",
 63             "50",
 64             "51",
 65             "52",
 66             "53",
 67             "54",
 68             "61",
 69             "62",
 70             "63",
 71             "64",
 72             "65",
 73             "71",
 74             "81",
 75             "82",
 76             "91" };
 77 
 78     /** 每位加权因子 */
 79     public static final int[] power = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
 80 
 81     /** 第18位校检码 */
 82     public static final String[] verifyCode = { "1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2" };
 83     /** 最低年限 */
 84     public static final int MIN = 1930;
 85     public static Map<String, String> cityCodes = new HashMap<String, String>();
 86     /** 台湾身份首字母对应数字 */
 87     public static Map<String, Integer> twFirstCode = new HashMap<String, Integer>();
 88     /** 香港身份首字母对应数字 */
 89     public static Map<String, Integer> hkFirstCode = new HashMap<String, Integer>();
 90     static {
 91         cityCodes.put("11", "北京");
 92         cityCodes.put("12", "天津");
 93         cityCodes.put("13", "河北");
 94         cityCodes.put("14", "山西");
 95         cityCodes.put("15", "内蒙古");
 96         cityCodes.put("21", "辽宁");
 97         cityCodes.put("22", "吉林");
 98         cityCodes.put("23", "黑龙江");
 99         cityCodes.put("31", "上海");
100         cityCodes.put("32", "江苏");
101         cityCodes.put("33", "浙江");
102         cityCodes.put("34", "安徽");
103         cityCodes.put("35", "福建");
104         cityCodes.put("36", "江西");
105         cityCodes.put("37", "山东");
106         cityCodes.put("41", "河南");
107         cityCodes.put("42", "湖北");
108         cityCodes.put("43", "湖南");
109         cityCodes.put("44", "广东");
110         cityCodes.put("45", "广西");
111         cityCodes.put("46", "海南");
112         cityCodes.put("50", "重庆");
113         cityCodes.put("51", "四川");
114         cityCodes.put("52", "贵州");
115         cityCodes.put("53", "云南");
116         cityCodes.put("54", "西藏");
117         cityCodes.put("61", "陕西");
118         cityCodes.put("62", "甘肃");
119         cityCodes.put("63", "青海");
120         cityCodes.put("64", "宁夏");
121         cityCodes.put("65", "新疆");
122         cityCodes.put("71", "台湾");
123         cityCodes.put("81", "香港");
124         cityCodes.put("82", "澳门");
125         cityCodes.put("91", "国外");
126         twFirstCode.put("A", 10);
127         twFirstCode.put("B", 11);
128         twFirstCode.put("C", 12);
129         twFirstCode.put("D", 13);
130         twFirstCode.put("E", 14);
131         twFirstCode.put("F", 15);
132         twFirstCode.put("G", 16);
133         twFirstCode.put("H", 17);
134         twFirstCode.put("J", 18);
135         twFirstCode.put("K", 19);
136         twFirstCode.put("L", 20);
137         twFirstCode.put("M", 21);
138         twFirstCode.put("N", 22);
139         twFirstCode.put("P", 23);
140         twFirstCode.put("Q", 24);
141         twFirstCode.put("R", 25);
142         twFirstCode.put("S", 26);
143         twFirstCode.put("T", 27);
144         twFirstCode.put("U", 28);
145         twFirstCode.put("V", 29);
146         twFirstCode.put("X", 30);
147         twFirstCode.put("Y", 31);
148         twFirstCode.put("W", 32);
149         twFirstCode.put("Z", 33);
150         twFirstCode.put("I", 34);
151         twFirstCode.put("O", 35);
152         hkFirstCode.put("A", 1);
153         hkFirstCode.put("B", 2);
154         hkFirstCode.put("C", 3);
155         hkFirstCode.put("R", 18);
156         hkFirstCode.put("U", 21);
157         hkFirstCode.put("Z", 26);
158         hkFirstCode.put("X", 24);
159         hkFirstCode.put("W", 23);
160         hkFirstCode.put("O", 15);
161         hkFirstCode.put("N", 14);
162     }
163 
164     /**
165      * 将15位身份证号码转换为18位
166      * @param idCard 15位身份编码
167      * @return 18位身份编码
168      */
169     public static String conver15CardTo18(String idCard) {
170         String idCard18 = "";
171         if (idCard.length() != CHINA_ID_MIN_LENGTH) {
172             return null;
173         }
174         if (isNum(idCard)) {
175             // 获取出生年月日
176             String birthday = idCard.substring(6, 12);
177             Date birthDate = null;
178             try {
179                 birthDate = new SimpleDateFormat("yyMMdd").parse(birthday);
180             } catch (ParseException e) {
181                 e.printStackTrace();
182             }
183             Calendar cal = Calendar.getInstance();
184             if (birthDate != null) {
185                 cal.setTime(birthDate);
186             }
187             // 获取出生年(完全表现形式,如:2010)
188             String sYear = String.valueOf(cal.get(Calendar.YEAR));
189             idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8);
190             // 转换字符数组
191             char[] cArr = idCard18.toCharArray();
192             if (cArr != null) {
193                 int[] iCard = converCharToInt(cArr);
194                 int iSum17 = getPowerSum(iCard);
195                 // 获取校验位
196                 String sVal = getCheckCode18(iSum17);
197                 if (sVal.length() > 0) {
198                     idCard18 += sVal;
199                 } else {
200                     return null;
201                 }
202             }
203         } else {
204             return null;
205         }
206         return idCard18;
207     }
208 
209     /**
210      * 验证身份证是否合法
211      */
212     public static boolean validateCard(String idCard) {
213         String card = idCard.trim();
214         if (validateIdCard18(card)) {
215             return true;
216         }
217         if (validateIdCard15(card)) {
218             return true;
219         }
220         String[] cardval = validateIdCard10(card);
221         if (cardval != null) {
222             if ("true".equals(cardval[2])) {
223                 return true;
224             }
225         }
226         return false;
227     }
228 
229     /**
230      * 验证18位身份编码是否合法
231      * @param idCard  身份编码
232      * @return 是否合法
233      */
234     public static boolean validateIdCard18(String idCard) {
235         boolean bTrue = false;
236         if (idCard.length() == CHINA_ID_MAX_LENGTH) {
237             // 前17位
238             String code17 = idCard.substring(0, 17);
239             // 第18位
240             String code18 = idCard.substring(17, CHINA_ID_MAX_LENGTH);
241             if (isNum(code17)) {
242                 char[] cArr = code17.toCharArray();
243                 if (cArr != null) {
244                     int[] iCard = converCharToInt(cArr);
245                     int iSum17 = getPowerSum(iCard);
246                     // 获取校验位
247                     String val = getCheckCode18(iSum17);
248                     if (val.length() > 0 && val.equalsIgnoreCase(code18)) {
249                         bTrue = true;
250                     }
251                 }
252             }
253         }
254         return bTrue;
255     }
256 
257     /**
258      * 验证15位身份编码是否合法
259      * @param idCard  身份编码
260      * @return 是否合法
261      */
262     public static boolean validateIdCard15(String idCard) {
263         if (idCard.length() != CHINA_ID_MIN_LENGTH) {
264             return false;
265         }
266         if (isNum(idCard)) {
267             String proCode = idCard.substring(0, 2);
268             if (cityCodes.get(proCode) == null) {
269                 return false;
270             }
271             String birthCode = idCard.substring(6, 12);
272             Date birthDate = null;
273             try {
274                 birthDate = new SimpleDateFormat("yy").parse(birthCode.substring(0, 2));
275             } catch (ParseException e) {
276                 e.printStackTrace();
277             }
278             Calendar cal = Calendar.getInstance();
279             if (birthDate != null) {
280                 cal.setTime(birthDate);
281             }
282             if (!valiDate(cal.get(Calendar.YEAR), Integer.valueOf(birthCode.substring(2, 4)), Integer.valueOf(birthCode.substring(4, 6)))) {
283                 return false;
284             }
285         } else {
286             return false;
287         }
288         return true;
289     }
290 
291     /**
292      * 验证10位身份编码是否合法
293      * @param idCard 身份编码
294      * @return 身份证信息数组
295      *         <p>
296      *         [0] - 台湾、澳门、香港 [1] - 性别(男M,女F,未知N) [2] - 是否合法(合法true,不合法false)
297      *         若不是身份证件号码则返回null
298      *         </p>
299      */
300     public static String[] validateIdCard10(String idCard) {
301         String[] info = new String[3];
302         String card = idCard.replaceAll("[\\(|\\)]", "");
303         if (card.length() != 8 && card.length() != 9 && idCard.length() != 10) {
304             return null;
305         }
306         if (idCard.matches("^[a-zA-Z][0-9]{9}{1}")) { // 台湾
307             info[0] = "台湾";
308             System.out.println("11111");
309             String char2 = idCard.substring(1, 2);
310             if ("1".equals(char2)) {
311                 info[1] = "M";
312                 System.out.println("MMMMMMM");
313             } else if ("2".equals(char2)) {
314                 info[1] = "F";
315                 System.out.println("FFFFFFF");
316             } else {
317                 info[1] = "N";
318                 info[2] = "false";
319                 System.out.println("NNNN");
320                 return info;
321             }
322             info[2] = validateTWCard(idCard) ? "true" : "false";
323         } else if (idCard.matches("^[1|5|7][0-9]{6}\\(?[0-9A-Z]\\)?{1}")) { // 澳门
324             info[0] = "澳门";
325             info[1] = "N";
326         } else if (idCard.matches("^[A-Z]{1,2}[0-9]{6}\\(?[0-9A]\\)?{1}")) { // 香港
327             info[0] = "香港";
328             info[1] = "N";
329             info[2] = validateHKCard(idCard) ? "true" : "false";
330         } else {
331             return null;
332         }
333         return info;
334     }
335 
336     /**
337      * 验证台湾身份证号码
338      * @param idCard 身份证号码
339      * @return 验证码是否符合
340      */
341     public static boolean validateTWCard(String idCard) {
342         String start = idCard.substring(0, 1);
343         String mid = idCard.substring(1, 9);
344         String end = idCard.substring(9, 10);
345         Integer iStart = twFirstCode.get(start);
346         Integer sum = iStart / 10 + ( iStart % 10 ) * 9;
347         char[] chars = mid.toCharArray();
348         Integer iflag = 8;
349         for (char c : chars) {
350             sum = sum + Integer.valueOf(c + "") * iflag;
351             iflag--;
352         }
353         return ( sum % 10 == 0 ? 0 : ( 10 - sum % 10 ) ) == Integer.valueOf(end) ? true : false;
354     }
355 
356     /**
357      * 验证香港身份证号码(存在Bug,部份特殊身份证无法检查)
358      * <p>
359      * 身份证前2位为英文字符,如果只出现一个英文字符则表示第一位是空格,对应数字58 前2位英文字符A-Z分别对应数字10-35
360      * 最后一位校验码为0-9的数字加上字符"A","A"代表10
361      * </p>
362      * <p>
363      * 将身份证号码全部转换为数字,分别对应乘9-1相加的总和,整除11则证件号码有效
364      * </p>
365      * @param idCard  身份证号码
366      * @return 验证码是否符合
367      */
368     public static boolean validateHKCard(String idCard) {
369         String card = idCard.replaceAll("[\\(|\\)]", "");
370         Integer sum = 0;
371         if (card.length() == 9) {
372             sum =
373                     ( Integer.valueOf(card.substring(0, 1).toUpperCase().toCharArray()[0]) - 55 ) * 9
374                             + ( Integer.valueOf(card.substring(1, 2).toUpperCase().toCharArray()[0]) - 55 ) * 8;
375             card = card.substring(1, 9);
376         } else {
377             sum = 522 + ( Integer.valueOf(card.substring(0, 1).toUpperCase().toCharArray()[0]) - 55 ) * 8;
378         }
379         String mid = card.substring(1, 7);
380         String end = card.substring(7, 8);
381         char[] chars = mid.toCharArray();
382         Integer iflag = 7;
383         for (char c : chars) {
384             sum = sum + Integer.valueOf(c + "") * iflag;
385             iflag--;
386         }
387         if ("A".equals(end.toUpperCase())) {
388             sum = sum + 10;
389         } else {
390             sum = sum + Integer.valueOf(end);
391         }
392         return ( sum % 11 == 0 ) ? true : false;
393     }
394 
395     /**
396      * 将字符数组转换成数字数组
397      * @param ca  字符数组
398      * @return 数字数组
399      */
400     public static int[] converCharToInt(char[] ca) {
401         int len = ca.length;
402         int[] iArr = new int[len];
403         try {
404             for (int i = 0; i < len; i++) {
405                 iArr[i] = Integer.parseInt(String.valueOf(ca[i]));
406             }
407         } catch (NumberFormatException e) {
408             e.printStackTrace();
409         }
410         return iArr;
411     }
412 
413     /**
414      * 将身份证的每位和对应位的加权因子相乘之后,再得到和值
415      * @param iArr
416      * @return 身份证编码。
417      */
418     public static int getPowerSum(int[] iArr) {
419         int iSum = 0;
420         if (power.length == iArr.length) {
421             for (int i = 0; i < iArr.length; i++) {
422                 for (int j = 0; j < power.length; j++) {
423                     if (i == j) {
424                         iSum = iSum + iArr[i] * power[j];
425                     }
426                 }
427             }
428         }
429         return iSum;
430     }
431 
432     /**
433      * 将power和值与11取模获得余数进行校验码判断
434      * @param iSum
435      * @return 校验位
436      */
437     public static String getCheckCode18(int iSum) {
438         String sCode = "";
439         switch (iSum % 11) {
440         case 10:
441             sCode = "2";
442             break;
443         case 9:
444             sCode = "3";
445             break;
446         case 8:
447             sCode = "4";
448             break;
449         case 7:
450             sCode = "5";
451             break;
452         case 6:
453             sCode = "6";
454             break;
455         case 5:
456             sCode = "7";
457             break;
458         case 4:
459             sCode = "8";
460             break;
461         case 3:
462             sCode = "9";
463             break;
464         case 2:
465             sCode = "x";
466             break;
467         case 1:
468             sCode = "0";
469             break;
470         case 0:
471             sCode = "1";
472             break;
473         default:
474             sCode = "-1";
475         }
476         return sCode;
477     }
478 
479     /**
480      * 根据身份编号获取年龄
481      * @param idCard  身份编号
482      * @return 年龄
483      */
484     public static int getAgeByIdCard(String idCard) {
485         int iAge = 0;
486         if (idCard.length() == CHINA_ID_MIN_LENGTH) {
487             idCard = conver15CardTo18(idCard);
488         }
489         String year = idCard.substring(6, 10);
490         Calendar cal = Calendar.getInstance();
491         int iCurrYear = cal.get(Calendar.YEAR);
492         iAge = iCurrYear - Integer.valueOf(year);
493         return iAge;
494     }
495 
496     /**
497      * 根据身份编号获取生日
498      * @param idCard 身份编号
499      * @return 生日(yyyyMMdd)
500      */
501     public static String getBirthByIdCard(String idCard) {
502         Integer len = idCard.length();
503         if (len < CHINA_ID_MIN_LENGTH) {
504             return null;
505         } else if (len == CHINA_ID_MIN_LENGTH) {
506             idCard = conver15CardTo18(idCard);
507         }
508         return idCard.substring(6, 14);
509     }
510 
511     /**
512      * 根据身份编号获取生日年
513      * @param idCard  身份编号
514      * @return 生日(yyyy)
515      */
516     public static Short getYearByIdCard(String idCard) {
517         Integer len = idCard.length();
518         if (len < CHINA_ID_MIN_LENGTH) {
519             return null;
520         } else if (len == CHINA_ID_MIN_LENGTH) {
521             idCard = conver15CardTo18(idCard);
522         }
523         return Short.valueOf(idCard.substring(6, 10));
524     }
525 
526     /**
527      * 根据身份编号获取生日月
528      * @param idCard 身份编号
529      * @return 生日(MM)
530      */
531     public static Short getMonthByIdCard(String idCard) {
532         Integer len = idCard.length();
533         if (len < CHINA_ID_MIN_LENGTH) {
534             return null;
535         } else if (len == CHINA_ID_MIN_LENGTH) {
536             idCard = conver15CardTo18(idCard);
537         }
538         return Short.valueOf(idCard.substring(10, 12));
539     }
540 
541     /**
542      * 根据身份编号获取生日天
543      * @param idCard  身份编号
544      * @return 生日(dd)
545      */
546     public static Short getDateByIdCard(String idCard) {
547         Integer len = idCard.length();
548         if (len < CHINA_ID_MIN_LENGTH) {
549             return null;
550         } else if (len == CHINA_ID_MIN_LENGTH) {
551             idCard = conver15CardTo18(idCard);
552         }
553         return Short.valueOf(idCard.substring(12, 14));
554     }
555 
556     /**
557      * 根据身份编号获取性别
558      * @param idCard  身份编号
559      * @return 性别(M-男,F-女,N-未知)
560      */
561     public static String getGenderByIdCard(String idCard) {
562         String sGender = "N";
563         if (idCard.length() == CHINA_ID_MIN_LENGTH) {
564             idCard = conver15CardTo18(idCard);
565         }
566         String sCardNum = idCard.substring(16, 17);
567         if (Integer.parseInt(sCardNum) % 2 != 0) {
568             sGender = "M";
569         } else {
570             sGender = "F";
571         }
572         return sGender;
573     }
574 
575     /**
576      * 根据身份编号获取户籍省份
577      * @param idCard 身份编码
578      * @return 省级编码。
579      */
580     public static String getProvinceByIdCard(String idCard) {
581         int len = idCard.length();
582         String sProvince = null;
583         String sProvinNum = "";
584         if (len == CHINA_ID_MIN_LENGTH || len == CHINA_ID_MAX_LENGTH) {
585             sProvinNum = idCard.substring(0, 2);
586         }
587         sProvince = cityCodes.get(sProvinNum);
588         return sProvince;
589     }
590 
591     /**
592      * 数字验证
593      * @param val
594      * @return 提取的数字。
595      */
596     public static boolean isNum(String val) {
597         return val == null || "".equals(val) ? false : val.matches("^[0-9]*{1}");
598     }
599 
600     /**
601      * 验证小于当前日期 是否有效
602      * @param iYear  待验证日期(年)
603      * @param iMonth 待验证日期(月 1-12)
604      * @param iDate 待验证日期(日)
605      * @return 是否有效
606      */
607     public static boolean valiDate(int iYear, int iMonth, int iDate) {
608         Calendar cal = Calendar.getInstance();
609         int year = cal.get(Calendar.YEAR);
610         int datePerMonth;
611         if (iYear < MIN || iYear >= year) {
612             return false;
613         }
614         if (iMonth < 1 || iMonth > 12) {
615             return false;
616         }
617         switch (iMonth) {
618         case 4:
619         case 6:
620         case 9:
621         case 11:
622             datePerMonth = 30;
623             break;
624         case 2:
625             boolean dm = ( ( iYear % 4 == 0 && iYear % 100 != 0 ) || ( iYear % 400 == 0 ) ) && ( iYear > MIN && iYear < year );
626             datePerMonth = dm ? 29 : 28;
627             break;
628         default:
629             datePerMonth = 31;
630         }
631         return ( iDate >= 1 ) && ( iDate <= datePerMonth );
632     }
633 
634     /**
635      * 根据身份证号,自动获取对应的星座
636      * @param idCard 身份证号码
637      * @return 星座
638      */
639     public static String getConstellationById(String idCard) {
640         if (!validateCard(idCard)) {
641             return "";
642         }
643         int month = IdCardUtils.getMonthByIdCard(idCard);
644         int day = IdCardUtils.getDateByIdCard(idCard);
645         String strValue = "";
646 
647         if ( ( month == 1 && day >= 20 ) || ( month == 2 && day <= 18 )) {
648             strValue = "水瓶座";
649         } else if ( ( month == 2 && day >= 19 ) || ( month == 3 && day <= 20 )) {
650             strValue = "双鱼座";
651         } else if ( ( month == 3 && day > 20 ) || ( month == 4 && day <= 19 )) {
652             strValue = "白羊座";
653         } else if ( ( month == 4 && day >= 20 ) || ( month == 5 && day <= 20 )) {
654             strValue = "金牛座";
655         } else if ( ( month == 5 && day >= 21 ) || ( month == 6 && day <= 21 )) {
656             strValue = "双子座";
657         } else if ( ( month == 6 && day > 21 ) || ( month == 7 && day <= 22 )) {
658             strValue = "巨蟹座";
659         } else if ( ( month == 7 && day > 22 ) || ( month == 8 && day <= 22 )) {
660             strValue = "狮子座";
661         } else if ( ( month == 8 && day >= 23 ) || ( month == 9 && day <= 22 )) {
662             strValue = "处女座";
663         } else if ( ( month == 9 && day >= 23 ) || ( month == 10 && day <= 23 )) {
664             strValue = "天秤座";
665         } else if ( ( month == 10 && day > 23 ) || ( month == 11 && day <= 22 )) {
666             strValue = "天蝎座";
667         } else if ( ( month == 11 && day > 22 ) || ( month == 12 && day <= 21 )) {
668             strValue = "射手座";
669         } else if ( ( month == 12 && day > 21 ) || ( month == 1 && day <= 19 )) {
670             strValue = "魔羯座";
671         }
672 
673         return strValue;
674     }
675 
676     /**
677      * 根据身份证号,自动获取对应的生肖
678      * @param idCard  身份证号码
679      * @return 生肖
680      */
681     public static String getZodiacById(String idCard) { // 根据身份证号,自动返回对应的生肖
682         if (!validateCard(idCard)) {
683             return "";
684         }
685         String[] sSX = { "猪", "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗" };
686         int year = IdCardUtils.getYearByIdCard(idCard);
687         int end = 3;
688         int x = ( year - end ) % 12;
689         String retValue = "";
690         retValue = sSX[x];
691 
692         return retValue;
693     }
694 
695     /**
696      * 根据身份证号,自动获取对应的天干地支
697      * @param idCard  身份证号码
698      * @return 天干地支
699      */
700     public static String getChineseEraById(String idCard) { // 根据身份证号,自动返回对应的生肖
701         if (!validateCard(idCard)) {
702             return "";
703         }
704         String[] sTG = { "癸", "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "任" };
705         String[] sDZ = { "亥", "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌" };
706 
707         int year = IdCardUtils.getYearByIdCard(idCard);
708         int i = ( year - 3 ) % 10;
709         int j = ( year - 3 ) % 12;
710 
711         String retValue = "";
712         retValue = sTG[i] + sDZ[j];
713 
714         return retValue;
715     }
716 
717     /**
718      * Test for Jason
719      */
720     public static void main(String[] args) {
721         String idCard = "430601199411151234";
722         System.out.println(IdCardUtils.getGenderByIdCard(idCard));
723         System.out.println(IdCardUtils.getBirthByIdCard(idCard));
724         System.out.println(IdCardUtils.getMonthByIdCard(idCard));
725         System.out.println(IdCardUtils.getDateByIdCard(idCard));
726         System.out.println(IdCardUtils.getConstellationById(idCard));
727         System.out.println(IdCardUtils.getZodiacById(idCard));
728         System.out.println(IdCardUtils.getChineseEraById(idCard));
729         System.out.println(IdCardUtils.getProvinceByIdCard(idCard));
730         //M 19941115 11 15 天蝎座 狗 甲戌 湖南
731     }
732 }

 

posted @ 2018-06-14 20:10  安以北往南  阅读(1802)  评论(0编辑  收藏  举报