From a01d637e9ff2bf26aa44c65a239413a38bd8b1fe Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 04 六月 2025 09:39:13 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0.1' into 2.0.1
---
server/service/src/main/java/com/doumee/core/utils/Constants.java | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/core/utils/Constants.java b/server/service/src/main/java/com/doumee/core/utils/Constants.java
index 81902fb..be029a4 100644
--- a/server/service/src/main/java/com/doumee/core/utils/Constants.java
+++ b/server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -321,22 +321,34 @@
}
public static int calculateAge(String idCard,Date dateDate) {
- if (idCard == null || idCard.length() != 18) {
- throw new IllegalArgumentException("韬唤璇佸彿鐮佸繀椤绘槸18浣�");
+ try{
+ Integer happenYear = Integer.valueOf(DateUtil.dateToString(dateDate,"yyyy"));
+ Integer birthYear = Integer.valueOf(idCard.substring(6,10));
+ return happenYear - birthYear;
+ }catch (Exception e){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"骞撮緞淇℃伅閿欒");
}
- // 鎻愬彇鍑虹敓鏃ユ湡
- String birthDateStr = idCard.substring(6, 14); // 渚嬪锛�19900101
- LocalDate birthDate = LocalDate.parse(birthDateStr);
- Instant instant = dateDate.toInstant();
- // 鑾峰彇褰撳墠鏃ユ湡
- LocalDate currentDate = instant.atZone(ZoneId.systemDefault()).toLocalDate(); // 杞崲涓� LocalDate
- // 璁$畻骞撮緞
- Period period = Period.between(birthDate, currentDate);
- int age = period.getYears(); // 鐩存帴鑾峰彇骞翠唤宸嵆涓哄勾榫�
- return age;
+
+
+// if (idCard == null || idCard.length() != 18) {
+// throw new IllegalArgumentException("韬唤璇佸彿鐮佸繀椤绘槸18浣�");
+// }
+//
+// // 鎻愬彇鍑虹敓鏃ユ湡
+// String birthDateStr = idCard.substring(6, 14); // 渚嬪锛�19900101
+// LocalDate birthDate = LocalDate.parse(birthDateStr);
+// Instant instant = dateDate.toInstant();
+// // 鑾峰彇褰撳墠鏃ユ湡
+// LocalDate currentDate = instant.atZone(ZoneId.systemDefault()).toLocalDate(); // 杞崲涓� LocalDate
+//
+// // 璁$畻骞撮緞
+// Period period = Period.between(birthDate, currentDate);
+// int age = period.getYears(); // 鐩存帴鑾峰彇骞翠唤宸嵆涓哄勾榫�
+
+// return age;
}
--
Gitblit v1.9.3