xiaoxiaoguai

java 通过身份证号计算年龄

public static int IdNOToAge(String IdNO){
        int leh = IdNO.length();
        String dates="";
        if (leh == 18) {
            int se = Integer.valueOf(IdNO.substring(leh - 1)) % 2;
            dates = IdNO.substring(6, 10);
            SimpleDateFormat df = new SimpleDateFormat("yyyy");
            String year=df.format(new Date());
            int u=Integer.parseInt(year)-Integer.parseInt(dates);
            return u;
        }else{
            dates = IdNO.substring(6, 8);
            return Integer.parseInt(dates);
        }

    }

 

发表于 2018-01-12 10:07  小小怪兽  阅读(5842)  评论(1编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-12-04
  • 2022-12-23
  • 2021-07-25
  • 2021-12-08
  • 2021-11-30
  • 2021-10-28
  • 2021-11-17
  • 2021-12-14
猜你喜欢
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-02-28
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案