`

通过身份证号码查询个人身份信息

    博客分类:
  • java
 
阅读更多
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 身份证号查询

    使用Java写的身份证分析程序,可以根据身份证信息获取地点,年龄等等信息。

    数字编码-身份证号码的秘密.pdf

    2. 身份证号码:用于识别和证明个人的身份。 3. 车牌号码:用于识别和管理机动车辆。 数字编码的方法可以分为以下几种: 1. 数字编码:使用数字来描述事物,例如身份证号码、车牌号码等。 2. 字符编码:使用字符来...

    Excel通过身份证号识别性别.docx

    身份证号码是中国公民的身份证明文件,它包含了公民的个人信息,包括姓名、性别、出生日期、地址等。在身份证号码中,最后一位数字可以用来判断性别,奇数为男性,偶数为女性。 那么,我们如何使用 Excel 来实现...

    根据身份证号码自动提取性别和出生年月及求年龄的公式.doc

    身份证号码是中国大陆地区公民的唯一身份标识,包含了个人的一些基本信息,如性别、出生年月、地址等。在实际应用中,经常需要根据身份证号码自动提取这些信息,例如,在人事管理、社保管理、医疗保健等领域。下面将...

    基于二代身份证的人脸识别身份验证系统研究.pdf

    在论文中,作者首先对二代身份证的特点进行了分析,指出二代身份证是中国16岁以上成年人使用最为频繁的有效证件,携带持有者的惟一身份证编号、人脸相片和个人基本信息。然后,作者对基于二代身份证的人脸识别身份...

    身份证号码妙用VB语句

    身份证号码妙用VB语句,提取里面的相关资料,很方便实用,

    社保查询个人账户.doc

    这种查询方式方便、快捷、安全,个人可以随时随地查询自己的社保信息。 二、社保查询个人账户的方法 社保查询个人账户有两种方法:网上方法和网下方法。 2.1 网上方法 1、第一步,上网打开百度,...

    基于身份证的人脸识别技术综述.pdf

    身份鉴别是指通过身份证中的人脸照片来确认个人的身份,而身份验证则是指通过身份证和其他证件来验证个人的身份。 在专利技术方面,本文梳理了基于身份证的人脸识别技术相关的专利技术,包括系统集成、特征提取、...

    身份证不合法错误筛选

    身份证号码是按照一定规律编制的,是个人身份的有效证明,每个人只有一个号码,且不会重复,在大量的身份证号码录入过程中,由于抄写或录入等原因,可能会弄错了某位数字。 如果录错了,校验未通过,则说明你录入的...

    个人信息表.doc

    身份证号是个人基本信息的第三个重要信息,是个人身份的唯一标识。身份证号是由公安机关颁发的,用于标识个人身份。真实的身份证号是130682200205250314。 生日是个人基本信息的第四个重要信息,是个人出生日期的...

    广州临时身份证可以办银行卡.doc

    身份证是验证个人身份的唯一证明文件,只有通过身份验证,银行才能确保客户的身份真实性。 2.在银行大堂答工作人员的协助下填写表格。 在银行卡办理流程中,客户需要填写表格,表格中需要提供个人信息,如姓名、...

    签证办理专用身份证英文模版分享.pdf

    这些信息都是签证办理时需要提交的身份证件信息,用于证明申请人的身份和身份信息。该模版提供了一个标准化的格式,方便申请人填写和提交相关信息。 该文件提供了一个签证办理专用的身份证英文模版,旨在帮助中国...

    社保修改个人信息情况说明怎么写.docx

    知识点:公民身份号码是社保个人信息登记表中的必录项,内容应与公安机关核发的 18 位公民身份证号码相同。 6. 诞生日期:应与居民身份证或居民户口簿全都,为必录项。 知识点:诞生日期是社保个人信息登记表中的...

    附件2:学信网学籍电子注册—身份证号重复的解决办法.doc

    在登录系统后,在个人信息页面,点击“【解决办法】”可以看到解决途径来进行身份信息审核:APP 自助验证通过后,将会注销使用了您当前证件号码的其他账号。如果您另有其他账号,请慎重此操作;注销账号会暂时影响您...

    姓名代码查询姓名代码在线查询代码查询区位码查询.pdf

    通过姓名代码查询,可以快速获取个人信息,提高工作效率和服务质量。 姓名代码在线查询是指通过互联网或移动端应用程序对姓名代码进行在线查询的过程。这种查询方式便捷、快速、准确,广泛应用于各个领域,例如人力...

    北京社会保险个人信息登记表.pdf

    该表格包含了个人基本信息、社会保险登记信息、户口信息、居住地信息、参加工作信息、个人身份信息等内容。 知识点1:社会保险登记证编码 社会保险登记证编码是社会保险经办机构依照有关规定核发的社会保险登记证...

    神盾身份证读卡器使用手册[参照].pdf

    该设备采用国际上先进的TypeB非接触IC卡阅读技术,以无线传输方式与第二代居民身份证内的专用芯片进行数据交换,可以将芯片内的个人信息资料读出,再通过计算机通讯接口,将此信息上传至计算机。 二、智能接口技术 ...

    IOS 身份证校验详细介绍及示例代码

    IOS 身份证校验 身份证基础知识: 身份证是国民的身份编号... 居民身份证是国家法定的证明公民个人身份的有效证件。 结构和形式 1.号码的结构  公民身份号码是特征组合码,由十七位数字本体码和一位校验码组成。排

    个人简历表格免费下载.pdf

    * 身份证号码:记录个人的身份证号码,用于验证个人的身份。 * 民族:记录个人的民族,用于了解个人的种族特征。 * 政治面貌:记录个人的政治面貌,用于了解个人的政治倾向。 二、教育背景 * 学历:记录个人的学历...

Global site tag (gtag.js) - Google Analytics