From eda58e0e6d4abdd2b060e28867d103045845aa69 Mon Sep 17 00:00:00 2001 From: 罗元桥 <2376770955@qq.com> Date: 星期一, 30 八月 2021 13:13:18 +0800 Subject: [PATCH] Merge branch 'test' into 'yuyue_dev' --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/IdCard.java | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 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 73aa44e..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; -- Gitblit v1.7.1