|
@@ -135,6 +135,9 @@ public final class IdCardUtil {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public static int getCurrentAgeCommon(Date date) {
|
|
public static int getCurrentAgeCommon(Date date) {
|
|
|
|
+ if (date == null) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
Calendar birthday = Calendar.getInstance();
|
|
Calendar birthday = Calendar.getInstance();
|
|
birthday.setTime(date);
|
|
birthday.setTime(date);
|
|
int year = birthday.get(Calendar.YEAR);
|
|
int year = birthday.get(Calendar.YEAR);
|
|
@@ -154,7 +157,7 @@ public final class IdCardUtil {
|
|
if (currentMonth < month || (currentMonth == month && currentDay <= day)) {
|
|
if (currentMonth < month || (currentMonth == month && currentDay <= day)) {
|
|
age--;
|
|
age--;
|
|
}
|
|
}
|
|
- return age < 0 ? 0 : age;
|
|
|
|
|
|
+ return Math.max(age, 0);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|