From 168dad051cd1b7276e9296741cce171a2e2d1ca9 Mon Sep 17 00:00:00 2001
From: yanghui <2536613402@qq.com>
Date: 星期四, 27 十月 2022 16:46:19 +0800
Subject: [PATCH] #feat 修改
---
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/IdCard.java | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 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 f5a0521..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
@@ -13,41 +13,41 @@
**/
public class IdCard {
- public static int IdNOToAge(String IdNO){
+ public static int IdNOToAge(String IdNO) {
int leh = IdNO.length();
- String dates="";
+ 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 {
+ age = Integer.parseInt(year) - Integer.parseInt(dates);
+ } else {
System.out.println("出错!身份证长度不是18位!");
}
return age;
}
- public static Date birthDay(String Id){
+ 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 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");//定义一个时间转换格式“年-月-日”
+ DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");// 定义一个时间转换格式“年-月-日”
Date date = null;
- try { //捕获类型转换(解析)异常
+ try { // 捕获类型转换(解析)异常
date = fmt.parse(birthday);
} catch (ParseException e) {
e.printStackTrace();
}
- return date;
+ return date;
}
- public static Integer sex(String id ){
+ public static Integer sex(String id) {
Integer sex;
if (Integer.parseInt(id.substring(16).substring(0, 1)) % 2 == 0) {// 判断性别
sex = 2;
@@ -55,10 +55,6 @@
sex = 1;
}
return sex;
- }
-
- public static String domicile(String cardId){
- return "四川省攀枝花市";
}
public static void main(String[] args) {
--
Gitblit v1.7.1