| | |
| | | package com.ltkj.framework.config; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.ltkj.common.utils.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Calendar; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | |
| | | /** |
| | | * @desc 通过身份证获取出生日期 |
| | | */ |
| | | public static String getBirthDayByIdCard(String idCard) throws Exception { |
| | | public static Date getBirthDayByIdCard(String idCard) throws Exception { |
| | | if (!isIdCard(idCard)) { |
| | | throw new Exception("身份证不正确"); |
| | | } |
| | |
| | | int year = Integer.parseInt(birth.substring(0, 4)); |
| | | int month = Integer.parseInt(birth.substring(4, 6)); |
| | | int day = Integer.parseInt(birth.substring(6, 8)); |
| | | return year + "-" + month + "-" + day; |
| | | String sr= year + "-" + month + "-" + day; |
| | | // 解析为 Date |
| | | Date date = DateUtil.parse(sr, "yyyy-MM-dd"); |
| | | // 转换为 LocalDateTime |
| | | LocalDateTime dateTime = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
| | | // 设置固定时分秒 |
| | | dateTime = dateTime.withHour(12).withMinute(34).withSecond(56); |
| | | return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | /** |