From a4380cdaeaa2bf5c317d29a242e442b70696f23b Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期日, 30 八月 2020 17:59:42 +0800
Subject: [PATCH] 优化缴费问题
---
java110-utils/src/main/java/com/java110/utils/util/CommonUtil.java | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/java110-utils/src/main/java/com/java110/utils/util/CommonUtil.java b/java110-utils/src/main/java/com/java110/utils/util/CommonUtil.java
index f4f6c5b..f5ace29 100644
--- a/java110-utils/src/main/java/com/java110/utils/util/CommonUtil.java
+++ b/java110-utils/src/main/java/com/java110/utils/util/CommonUtil.java
@@ -4,6 +4,9 @@
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.util.StringUtils;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.Random;
/**
@@ -95,4 +98,30 @@
}
return false;
}
+
+
+ /**
+ * 鏍规嵁韬唤璇佸彿鑾峰彇骞撮緞
+ * @param certId
+ * @return
+ */
+ public static String getAgeByCertId(String certId) {
+ String birthday = "";
+ if (certId.length() == 18) {
+ birthday = certId.substring(6, 10) + "/"
+ + certId.substring(10, 12) + "/"
+ + certId.substring(12, 14);
+ }
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+ Date now = new Date();
+ Date birth = new Date();
+ try {
+ birth = sdf.parse(birthday);
+ } catch (ParseException e) {
+ }
+ long intervalMilli = now.getTime() - birth.getTime();
+ int age = (int) (intervalMilli/(24 * 60 * 60 * 1000))/365;
+ System.out.println(age);
+ return age +"";
+ }
}
--
Gitblit v1.8.0