//根据身份证号得到年龄
public static int IdNOToAge(String IdNO){
int leh = IdNO.length();
String dates="";
if (leh == 18) {
dates = IdNO.substring(6, 10);
}else{
dates = IdNO.substring(6, 8);
dates = "19"+dates;
}
SimpleDateFormat df = new SimpleDateFormat("yyyy");
String year=df.format(new Date());
int u=Integer.parseInt(year)-Integer.parseInt(dates);
return u;
}
Java根据身份证号得到年龄通用方法
最新推荐文章于 2023-01-17 10:18:21 发布