package com.qb.modules.interfaces.befloan.common.util; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Map; import java.util.Set; public class IdcardInfoExtractor { // 省份 private String province; // 城市 private String city; // 区县 private String region; // 年份 private int year; // 月份 private int month; // 日期 private int day; // 性别 private String gender; // 出生日期 private Date birthday; //年龄 private int age; private Map<String, String> cityCodeMap = new HashMap<String, String>() { { this.put("11", "北京"); this.put("12", "天津"); this.put("13", "河北"); this.put("14", "山西"); this.put("15", "内蒙古"); this.put("21", "辽宁"); this.put("22", "吉林"); this.put("23", "黑龙江"); this.put("31", "上海"); this.put("32", "江苏"); this.put("33", "浙江"); this.put("34", "安徽"); this.put("35", "福建"); this.put("36", "江西"); this.put("37", "山东"); this.put("41", "河南"); this.put("42", "湖北"); this.put("43", "湖南"); this.put("44", "广东"); this.put("45", "广西"); this.put("46", "海南"); this.put("50", "重庆"); this.put("51", "四川"); this.put("52", "贵州"); this.put("53", "云南"); this.put("54", "西藏"); this.put("61", "陕西"); this.put("62", "甘肃"); this.put("63", "青海"); this.put("64", "宁夏"); this.put("65", "新疆"); this.put("71", "台湾"); this.put("81", "香港"); this.put("82", "澳门"); this.put("91", "国外"); } }; private IdcardValidator validator = null; /** * 通过构造方法初始化各个成员属性 */ public IdcardInfoExtractor(String idcard) { try { validator = new IdcardValidator(); if (validator.isValidatedAllIdcard(idcard)) { if (idcard.length() == 15) { idcard = validator.convertIdcarBy15bit(idcard); } // 获取省份 String provinceId = idcard.substring(0, 2); Set<String> key = this.cityCodeMap.keySet(); for (String id : key) { if (id.equals(provinceId)) { this.province = this.cityCodeMap.get(id); break; } } // 获取性别 String id17 = idcard.substring(16, 17); if (Integer.parseInt(id17) % 2 != 0) { this.gender = "男"; } else { this.gender = "女"; } // 获取出生日期 String birthday = idcard.substring(6, 14); Date birthdate = new SimpleDateFormat("yyyyMMdd") .parse(birthday); this.birthday = birthdate; GregorianCalendar currentDay = new GregorianCalendar(); currentDay.setTime(birthdate); this.year = currentDay.get(Calendar.YEAR); this.month = currentDay.get(Calendar.MONTH) + 1; this.day = currentDay.get(Calendar.DAY_OF_MONTH); //获取年龄 SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy"); String year=simpleDateFormat.format(new Date()); this.age=Integer.parseInt(year)-this.year; } } catch (Exception e) { e.printStackTrace(); } } /** * @return the province */ public String getProvince() { return province; } /** * @return the city */ public String getCity() { return city; } /** * @return the region */ public String getRegion() { return region; } /** * @return the year */ public int getYear() { return year; } /** * @return the month */ public int getMonth() { return month; } /** * @return the day */ public int getDay() { return day; } /** * @return the gender */ public String getGender() { return gender; } /** * @return the birthday */ public Date getBirthday() { return birthday; } @Override public String toString() { return "省份:" + this.province + ",性别:" + this.gender + ",出生日期:" + this.birthday; } public static void main(String[] args) { String idcard = ""; IdcardInfoExtractor ie = new IdcardInfoExtractor(idcard); System.out.println(ie.toString()); } public int getAge() { return age; } public void setAge(int age) { this.age = age; } }
相关推荐
使用Java写的身份证分析程序,可以根据身份证信息获取地点,年龄等等信息。
身份证号码妙用VB语句,提取里面的相关资料,很方便实用,
身份证号码是按照一定规律编制的,是个人身份的有效证明,每个人只有一个号码,且不会重复,在大量的身份证号码录入过程中,由于抄写或录入等原因,可能会弄错了某位数字。 如果录错了,校验未通过,则说明你录入的...
IOS 身份证校验 身份证基础知识: 身份证是国民的身份编号... 居民身份证是国家法定的证明公民个人身份的有效证件。 结构和形式 1.号码的结构 公民身份号码是特征组合码,由十七位数字本体码和一位校验码组成。排
我的页面通过填写基本信息、收藏、体征信息、饮食信息、热量查询、健康备忘录等信息,并可以进行修改信息 基本信息,在基本信息页面通过填写头像、昵称、修改头像、修改昵称、修改密码等信息进行填写 管理员登录,...
在预先登记人员身份信息和指纹信息后,通过按压手指来确认其身份,并以自定义的任务方式,记录人员的各种活动状态。由于每一个人的每一个手指的指纹信息是唯一性、不可仿造性,系统无需其他辅助身份证明物品就能正确...
表单验证个人身份信息提交审核,提交信息时弹窗提示消息,拿来即可使用,简单方便,没有冗余代码,希望大家能够得到帮助。
中国大陆个人身份证验证器(JS版),支持 AMD/CMD/CommonJS, 或浏览器直接使用。
1. **自动识别**:系统能够自动识别上传的身份证图片中的文本信息,如姓名、性别、民族和身份证号码等。 2. **实时考勤记录**:通过识别的身份证信息来记录员工的签到时间,实现自动化考勤。 3. **用户管理**:提供...
个人编写的用c++编写的身份证验证,内包含了各省市县的行政区号文件,和测试文件。
查询订票人详细信息: 精确查询:输入订票人身份证号码查询订票人详细信息。 航空订票管理系统软件项目管理课程设计报告全文共47页,当前为第4页。 模糊查询:输入订票人姓名(或订票人姓或是年龄或是性别)查询出一...
同时,身份证与数据库的关联意味着它们是用于社会分类的系统,允许通过可能包括种族和宗教的分类模式在不同人群之间进行广泛区分。 紧迫的挑战是建立避免排他性偏见的系统,其中处理个人数据的责任至高无上。 本期...
CMVisitors 访客登记系统,包含个人资料和照片。 按个人身份(身份证)索引的搜索
(1)学生可以在系统中注册个人信息,并使用该信息在系统中参与投票,该系统应该提供正规的用户身份验证机制,如学号或身份证号码等,保证用户身份的准确性和安全性; (1)学生可以在系统中查询个人参与的投票信息...
在现实生活中,我们拥有身份证、护照、驾照、企业工牌等,在以往,我们使用这些有着物理介质、或者部分电子化的凭据形式给出身份证明,但在互联网这个的大环境中,如何构造合理并可信的身份证明关系,使其具备数字化...
在系统里,考生可以通过身份证号和准考证号查询自己的成绩,可以进行在线问答。 为了方便系统管理员对考生个人信息的管理,在系统里系统管理员可以对考生进行操作:考生信息查询,修改,删除功能。 为了方便...
(1)学生可以在系统中注册个人信息,并使用该信息在系统中参与投票,该系统应该提供正规的用户身份验证机制,如学号或身份证号码等,保证用户身份的准确性和安全性; (2)学生可以在系统中查询个人参与的投票信息...
在系统里,考生可以通过身份证号和准考证号查询自己的成绩,可以进行在线问答。 为了方便系统管理员对考生个人信息的管理,在系统里系统管理员可以对考生进行操作:考生信息查询,修改,删除功能。 为了方便...
(1)学生可以在系统中注册个人信息,并使用该信息在系统中参与投票,该系统应该提供正规的用户身份验证机制,如学号或身份证号码等,保证用户身份的准确性和安全性; (2)学生可以在系统中查询个人参与的投票信息...
(1)学生可以在系统中注册个人信息,并使用该信息在系统中参与投票,该系统应该提供正规的用户身份验证机制,如学号或身份证号码等,保证用户身份的准确性和安全性; (2)学生可以在系统中查询个人参与的投票信息...