/****
     * 根据身份证号计算年龄
     * @param str  
     * @param currDate 
     * @return
     */
    public boolean calcYear(String str, Date currDate){
        DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        Long year = Long.parseLong(str.substring(0,4));
        Long month = Long.parseLong(str.substring(4,6));
        Long day = Long.parseLong(str.substring(6,8));
        String str1 = dateFormat.format(currDate);
        Long year1 = Long.parseLong(str1.substring(0,4));
        Long month1 = Long.parseLong(str1.substring(4,6));
        Long day1 = Long.parseLong(str1.substring(6,8));
        Long num = year1-year;
        Long mon = month1-month;
        Long day2 = day1-day;
        boolean bool= false;
        if(num<16){
            bool = true;
        }else if(num==16){
            if(mon<0||(mon==0 && day2<0)){
                bool = true;
            }else if(mon>0 ||(mon==0 && day2>=0)){
                bool = false;
            }
        }
        LOGGER.info("判断当前证件是未成年人的标识为:"+bool+"[True表示为未成年人,False表示为未成年人]");
        return bool;
    }

技术
今日推荐
PPT
阅读数 107
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信