通过身份证号判断大于或等于18岁

时间:2022-12-08 23:12:46

import java.util.Calendar;

 

String idcard = request.getParameter("idcard");//身份证
String chkidcard = idcard.toString().substring(6,10);//截取年
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
String fcm = "0";
if(Integer.parseInt(idcard)+18>=year)
{
        fcm="1";
}