如何识别身份证上的信息(根据身份证获取信息的方法)
如何识别身份证上的信息(根据身份证获取信息的方法)
2024-05-29 12:07:56  作者:安抚人心  网址:https://m.xinb2b.cn/know/apa423211.html

package com.hzrc.acl.authentication.security.util;import java.util.Calendar;public class getInfoByIdentityCodeUtil { private static boolean getValidIdentityCard(String identityCard){ if(identityCard == null || identityCard.length() == 0) return false; if(identityCard.length() != 18) return false; char[] identities = identityCard.toCharArray(); int code = 0; int[] number = new int[]{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1}; char[] numberArray = new char[]{'1','0','X','9','8','7','6','5','4','3','2'}; for(int i =0 ; i < 17; i ) { if(identities[i] < '0' || identities[i] > '9') { return false; } code = (identities[i] -'0') * number[i]; } code = code % 11; if(numberArray[code] != identities[17]) { return false; } return true; } public static Integer getGender(String identityCode) { if(identityCode == null || identityCode.length() == 0) return 0; int gender = 0; if(identityCode.length() == 18){ //如果身份证号18位,取身份证号倒数第二位 char c = identityCode.charAt(identityCode.length() - 2); gender = Integer.parseInt(String.valueOf(c)); }else{ //如果身份证号15位,取身份证号最后一位 char c = identityCode.charAt(identityCode.length() - 1); gender = Integer.parseInt(String.valueOf(c)); } if(gender % 2 == 1) return 1; return 2; } public static String getBirthday(String identityCode) { String birthday = null; if(identityCode == null || identityCode.length() == 0) return birthday; if (identityCode.length() == 15) { birthday = "19" identityCode.substring(6, 8) "-" identityCode.substring(8, 10) "-" identityCode.substring(10, 12); } else if (identityCode.length() == 18) { birthday = identityCode.substring(6, 10) "-" identityCode.substring(10, 12) "-" identityCode.substring(12, 14); } return birthday; } public static Integer getAge(String identityCode) { int age = 0; if(identityCode == null || identityCode.length() == 0) return age; int year = Calendar.getInstance().get(Calendar.YEAR); if (identityCode.length() == 15) { age = (year - Integer.parseInt("19" identityCode.substring(6, 8))); } else if (identityCode.length() == 18) { age = (year - Integer.parseInt(identityCode.substring(6, 10))); } return age; } public static String getNaticePlace(String identityCode) { if(identityCode == null || identityCode.length() == 0) return null; int nativePlaceCode=Integer.parseInt(identityCode.substring(0, 6)); return NativePlace.getNativePlace(nativePlaceCode); } public static void main(String[] args) { }}

获取籍贯,因为所有地区信息太多了,就不放在这里了,需要的可以评论,私发给你。

如何识别身份证上的信息(根据身份证获取信息的方法)(1)

知是行之始,行是知之成。

  • 在我看来世界的英语(我眼中的中文和英文)
  • 2024-05-29我眼中的中文和英文作为一个以英文养家糊口的人来说,对它我是爱恨交加爱它是因为它施舍我一口饭吃,恨它是因为教了这么多年没有什么长进,感觉是吃馍就蒜汁——越沾越少教英语从二十六个字母开始,单词句子都是它二十六个在嘚瑟,如同。
  • 海贼王鹰眼全部实力(海贼王第925话正式图文)
  • 2024-05-29海贼王第925话正式图文想必大家之前都看过了《海贼王》第925话的文字情报了吧,而现在正式版的图文终于来了,接下来我们来看看正式版的《海贼王》925话中都有什么吧!首先出场的是鹰眼和佩罗娜,两人如今在伟大航路的西凯阿尔王国的。
  • 搜集一些有关甲骨文的知识(一起写写甲骨文之五)
  • 2024-05-29一起写写甲骨文之五今天先写字,开始写甲骨文——甲骨文的笔画比较简单,主要有三种笔画,即点画、直画、曲画今天继续介绍直画直画,有横画、竖画和斜画三种变化今天选了“子”字,也是常用字之一子有多种字形,我选的是竖画多的字形,。
  • 京东雅典娜可以刷梅林固件吗(京豆赚不停WiFi6)
  • 2024-05-29京豆赚不停WiFi6利用闲置带宽换点零钱不是什么新鲜事,方法层出不穷,不过论及积分兑换稳定性和能源产出率,还属京东云无线宝更靠谱它本身就是一台高性能无线路由器,通过合理设置积分模式,可保证正常网络使用情况下自动均衡边缘计。
  • 水里蚊子幼虫能喂凤尾鱼吗(都知道红虫是摇蚊幼虫)
  • 2024-05-29都知道红虫是摇蚊幼虫哗仔说鱼对不起,我是哗仔!关注哗仔说鱼,明明白白养鱼大家好,我就是那个鱼和熊掌已经兼得的哗仔你用过红虫吗?相信有很多朋友用红虫喂过观赏鱼,那自然也有很多朋友知道红虫的本质就是摇蚊的幼虫可是,今天哗仔考。
  • anna英语原版阅读(英语原版阅读与写作)
  • 2024-05-29英语原版阅读与写作今天分享与学校话题相关的词汇和阅读,可以作为词汇和阅读学习的配套资源,也可以作为写作的学习资料每日10分钟英语阅读,养成习惯,孩子的英语学习不用愁这个话题的题目是:Swimminggala先来读相关的。
  • 引蛇出洞的成语故事(成语故事杯弓蛇影)
  • 2024-05-29成语故事杯弓蛇影西晋时期,有个叫乐广的人有一天,乐广请一位朋友到自己家里喝酒,喝着喝着,朋友忽然说自己有点不舒服就回家了此后过了很长一段时间,这个朋友都没有再来乐广想“难道是我招待不周,朋友生气了?”犹豫再三,乐广决。
  • 世界航空母舰最大排水量多少吨(世界上最大油轮排水量82万吨)
  • 2024-05-29世界上最大油轮排水量82万吨说起世界上最大的船,可能不少人都会首先想到航空母舰是啊,这种高端军用舰艇动辄拥有数万吨的满载排水量,加上霸气的外形,往往会给人留下十分深刻的印象但其实,航空母舰在巨型油轮面前,还是显得有些娇小世界上最。
  • 正宗广东清远鸡做法(这个农庄仅凭一道古法秘制清远鸡)
  • 2024-05-29这个农庄仅凭一道古法秘制清远鸡在英德市九龙镇喀斯特峰林深处,有一个特别不起眼的农庄,甚至一般人都找不到,却让广州一带的游客纷纷慕名而来,这是为什么呢?这处农庄叫罗老师庄园,位于九龙镇活石水村,距离峰林小镇景区大约3公里因为农庄老板。
  • 机器学习检测指标选择(衡量机器学习模型性能)
  • 2024-05-29衡量机器学习模型性能点击上方关注,AllinAI中国虽然有很多指标可以用来衡量机器学习模型的性能,如Accuracy和Recall,但ROC曲线和CAP曲线对于分类问题非常有用在本文中,我将探讨ROC和CAP是什么以及如。
  • 煮熟的黄豆怎么做最好吃(这样做出美味黄豆)
  • 2024-05-29这样做出美味黄豆腌制时间大概半个小时,将锅清洗干净,沥干水渍,加入适量的油,将油烧热,放入蒜末、姜丝、八角、桂皮、辣椒干爆香一会,然后倒入前面腌制的黄豆,大火快炒慢慢将水煮干,然后将黄豆装到一个碗中,加入盐巴、料酒、。