|
@ -95,7 +95,6 @@ public class IdCardUtil {
|
|
|
*/
|
|
|
public static int getAgeForIdcard(String idcard) {
|
|
|
int age = 0;
|
|
|
try{
|
|
|
|
|
|
if (StringUtils.isEmpty(idcard)) {
|
|
|
return age;
|
|
@ -115,12 +114,10 @@ public class IdCardUtil {
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
age = cal.get(Calendar.YEAR) - year;
|
|
|
//周岁计算
|
|
|
if (cal.get(Calendar.MONTH) > (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) > day)) {
|
|
|
if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) {
|
|
|
age--;
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
return age;
|
|
|
}
|
|
|
|
|
|
return age;
|
|
|
}
|
|
|
|