cloud-server-other/src/main/java/com/dsh/other/util/DateUtil.java
@@ -286,6 +286,7 @@ Calendar cal = Calendar.getInstance(); return cal; } /** * 毫秒转日期时间 * @@ -332,6 +333,7 @@ /** * 计算年龄 * * @param birthDate * @return */ @@ -355,9 +357,13 @@ // 粗计算年龄 int age = yearNow - yearBirth; // 当前月份小于出生月份年龄减一 if (monthNow < monthBirth) { age--; } if (monthNow < monthBirth) { age--; } // 当前月份等于出生月份,日小于生日年龄减一 else if (monthNow == monthBirth && dayNow < dayBirth) { age--; } else if (monthNow == monthBirth && dayNow < dayBirth) { age--; } // 返回年龄值 return age; }