From de15583e9bf3d33d86e42f61e3d7b28685d2afc0 Mon Sep 17 00:00:00 2001
From: lidongdong <1459917685@qq.com>
Date: 星期三, 23 八月 2023 16:00:32 +0800
Subject: [PATCH] 修改定时任务报名人数为空
---
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/IdCard.java | 71 +++++++++++++++++++++++++++++++----
1 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/IdCard.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/IdCard.java
index d764584..1b49c03 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/IdCard.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/IdCard.java
@@ -1,11 +1,64 @@
-package com.panzhihua.common.utlis;/**
-* @program: springcloud_k8s_panzhihuazhihuishequ
-*
-* @description: 年龄
-*
-* @author: huang.hongfa weixin hhf9596 qq 959656820
-*
-* @create: 2021-02-06 17:27
-**/
+package com.panzhihua.common.utlis;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @program: springcloud_k8s_panzhihuazhihuishequ
+ * @description: 年龄
+ * @author: huang.hongfa weixin hhf9596 qq 959656820
+ * @create: 2021-02-06 17:27
+ **/
public class IdCard {
+
+ public static int IdNOToAge(String IdNO) {
+ int leh = IdNO.length();
+ String dates = "";
+ int age = 0;
+ if (leh == 18) {
+ dates = IdNO.substring(6, 10);
+ SimpleDateFormat df = new SimpleDateFormat("yyyy");
+ String year = df.format(new Date());
+ age = Integer.parseInt(year) - Integer.parseInt(dates);
+ } else {
+ System.out.println("出错!身份证长度不是18位!");
+ }
+ return age;
+ }
+
+ public static Date birthDay(String Id) {
+ /*从身份证截取生日信息
+
+ * author:huangjy 2016-07-15 Date转换成String,只需将parse方法换成format方法
+ * */
+ String year = Id.substring(6, 10);// 调用substring方法返回相关字段,注意索引从0开始
+ String month = Id.substring(10, 12);
+ String day = Id.substring(12, 14);
+ String birthday = year + "-" + month + "-" + day;
+ DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");// 定义一个时间转换格式“年-月-日”
+ Date date = null;
+ try { // 捕获类型转换(解析)异常
+ date = fmt.parse(birthday);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return date;
+ }
+
+ public static Integer sex(String id) {
+ Integer sex;
+ if (Integer.parseInt(id.substring(16).substring(0, 1)) % 2 == 0) {// 判断性别
+ sex = 2;
+ } else {
+ sex = 1;
+ }
+ return sex;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(birthDay("120000197802150561"));
+ System.out.println(birthDay("32000019951110538X"));
+ }
}
--
Gitblit v1.7.1