java根据身份证号和获取用户信息工具类(性别,年龄)

java中根据身份证号求出生日期、年龄以及性别 根据身份证号求出生日期、年龄以及性别 根据身份证号求出对应的出生日期、年龄以及性别,身份证号工具类 话不多说,直接上代码 package com.demo.util; import org.apache.commons.lang3.StringUtils; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import static com.yihu.wlyy.util.Consta 阅读详情
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
 
/**
 * 身份证信息算法类
 * 
 * @author javaweb
 * 
 */
public class CardUtil {
 
    /**
     * 根据身份证的号码算出当前身份证持有者的性别和年龄 18位身份证
     * 
     * @return
     * @throws Exception
     */
    public static Map<String, Object> getCarInfo(String CardCode)
            throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        String year = CardCode.substring(6).substring(0, 4);// 得到年份
        String yue = CardCode.substring(10).substring(0, 2);// 得到月份
        // String day=CardCode.substring(12).substring(0,2);//得到日
        String sex;
        if (Integer.parseInt(CardCode.substring(16).substring(0, 1)) % 2 == 0) {// 判断性别
            sex = "女";
        } else {
            sex = "男";
        }
        Date date = new Date();// 得到当前的系统时间
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String fyear = format.format(date).substring(0, 4);// 当前年份
        String fyue = format.format(date).substring(5, 7);// 月份
        // String fday=format.format(date).substring(8,10);
        int age = 0;
        if (Integer.parseInt(yue) <= Integer.parseInt(fyue)) { // 当前月份大于用户出身的月份表示已过生
            age = Integer.parseInt(fyear) - Integer.parseInt(year) + 1;
        } else {// 当前用户还没过生
            age = Integer.parseInt(fyear) - Integer.parseInt(year);
        }
        map.put("sex", sex);
        map.put("age", age);
        return map;
    }
 
    /**
     * 15位身份证的验证
     * 
     * @param
     * @throws Exception
     */
    public static Map<String, Object> getCarInfo15W(String card)
            throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        String uyear = "19" + card.substring(6, 8);// 年份
        String uyue = card.substring(8, 10);// 月份
        // String uday=card.substring(10, 12);//日
        String usex = card.substring(14, 15);// 用户的性别
        String sex;
        if (Integer.parseInt(usex) % 2 == 0) {
            sex = "女";
        } else {
            sex = "男";
        }
        Date date = new Date();// 得到当前的系统时间
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String fyear = format.format(date).substring(0, 4);// 当前年份
        String fyue = format.format(date).substring(5, 7);// 月份
        // String fday=format.format(date).substring(8,10);
        int age = 0;
        if (Integer.parseInt(uyue) <= Integer.parseInt(fyue)) { // 当前月份大于用户出身的月份表示已过生
            age = Integer.parseInt(fyear) - Integer.parseInt(uyear) + 1;
        } else {// 当前用户还没过生
            age = Integer.parseInt(fyear) - Integer.parseInt(uyear);
        }
        map.put("sex", sex);
        map.put("age", age);
        return map;
    }
 
}
mysql根据身份证号查 性别、年龄以及出生日期 mysql根据身份证号查性别、年龄以及出生日期 博客里面还有对应的工具类:芜湖,起飞 这个身份证号也就只针对大陆身份证号 SELECT p.id, -- 这是根据身份证号求年龄 (YEAR(NOW())- SUBSTRING(p.idcard,7,4)) age, -- 这是根据身份证号求出生日期 cast(substring(p.idcard,7,8) as date) as '出生日期', -- 这是根据身份证号求性别 case if(length(idcard)=18, cast(substri 阅读详情

相关推荐

Java中怎么通过身份证解析出:年龄、性别、出生日期。

Java中怎么通过身份证解析出:年龄、性别、出生日期。下面是我写的一个java类 package com.thinkgem.jeesite.modules.cyry; import com.thinkgem.jeesite.modules.wcbxx.dao.WcbxxDao; import com.thinkgem.jeesite.modules.wcbxx.entity.Wcbx

学以致用 3万+

java 通过身份证号码得到用户的性别年龄

水水水水

张亮的博客 1万+

字符串替换—牛客网(C++实现)

一.题目描述 请你实现一个简单的字符串替换函数。原串中需要替换的占位符为"%s",请按照参数列表的顺序一一替换占位符。若参数列表的字符数大于占位符个数。则将剩下的参数字符添加到字符串的结尾。 给定一个字符串A,同时给定它的长度n及参数字符数组arg,请返回替换后的字符串。保证参数个数大于等于占位符个数。保证原串由大小写英文字母组成,同时长度小于等于500。 测试样例: “A%sC%sE”,7,[‘...

qq_38358582的博客 1522

java根据身份证号获取性别,年龄,生日等信息(工具类)

1,新建一个类,将下面代码拷贝进去 package com.sport.sportactivityserver.common.utils; import org.apache.commons.lang.StringUtils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /** * @Description:身份证号的util * @Author: zdj .

格林王子举哥 7116

西电2023秋季机器学习复习提纲

西电2023秋季机器学习复习提纲,希望对学弟学妹有帮助

weixin_62083045的博客 5649

CODESYS安装全攻略:从下载到配置的保姆级教程(含常见问题解决)

本文提供了一份详细的CODESYS安装与配置指南,涵盖从系统环境准备、安装包下载、Development System安装到Runtime System配置的全过程。教程重点解决了安装过程中的常见权限、兼容性和连接问题,并指导用户完成第一个PLC程序的创建与调试,帮助工业自动化开发者快速上手这一通用开发平台。

kkk56的博客 420

Java中根据身份证获取信息

Java中根据身份证获取信息,让你不再多写重复代码

ProBaiXiaodi的博客 1506

HMC5883L磁力计驱动开发:I²C通信、校准与FreeRTOS集成

磁力计是惯性导航与电子罗盘系统的核心传感器,其输出原始磁场数据需经精确采集、单位换算与误差补偿才能用于姿态解算。基于各向异性磁阻(AMR)原理的三轴磁力计,如HMC5883L,依赖稳定I²C通信获取12位有符号磁场采样值,并通过增益配置、硬软铁校准及温度补偿提升物理量精度。在嵌入式实时系统中,驱动层须保障数据的时间一致性与抗干扰鲁棒性,避免总线挂死、字节错位或量程误配等典型问题。本文围绕HMC5883L这一广泛使用的停产但仍在产线服役的磁传感器,详解寄存器配置、定点单位转换、八方位校准算法及FreeRTOS

weixin_42594427的博客 145

Java实现获取当前请求用户信息

Java实现当前请求用户信息

夕四 4238

Ubuntu 20.04 + CARLA 0.9.13 长时运行崩溃?手把手教你定位和缓解Segmentation fault

本文详细解析了Ubuntu 20.04环境下CARLA 0.9.13仿真平台长时运行崩溃问题,提供了从内存监控到核心转储分析的系统级诊断方法,并分享内存泄漏缓解、稳定性优化配置等实用解决方案,帮助开发者构建更稳定的自动驾驶仿真环境。

weixin_28362173的博客 253

百万 Token 压力实测:1M Context 的真实能力边界在哪里?

本文揭示了长上下文模型的性能衰减规律:1M上下文存在"容量曲线"与"质量曲线"的分歧,512K是可靠拐点。通过MRCR测试发现,不同任务类型衰减差异显著——检索任务在512K后性能下降30.6%,而生成任务仅下降5%。研究提出三阶段补偿策略:三明治注入(首尾指令强化)、语义面包屑(位置标记)、引用检查(强制溯源),可将512K-1M区间的可用性提升20%。工程实践表明,中段区域(30-70%位置)是注意力薄弱区,需要特殊处理。最终建议:关键检索任务控制在512K内,关联推理任务可扩展至

liuzhupeng的专栏 338

java获取当前登录人的工具类

获取当前登录人的工具类 package com.huitai.core.utils; import com.huitai.core.security.utils.CustomUser; import com.huitai.core.system.entity.HtSysUser; import com.huitai.core.system.service.HtSysUserService; import org.springframework.security.core.context.SecurityC

weixin_49075777的博客 1281

土壤数据库辅助工具SPAW计算土壤导水率

首先点击打开根据之前的1比100土壤数据查表得到各个组分含量其中Field Capacity是田间持水量Matric Bulk Density是基质粒密度。

所有专家都曾始于新手 3443

Java 根据身份证号获取性别、年龄、出生日期等信息

获取sfz信息

weixin_43989102的博客 7415

MIKE水动力笔记7_实测数据与模型输出结果的拟合对比

上一博文【MIKE水动力笔记6】主要讲解如何自己制作实测数据的时间序列文件dfs0,而本博文讲解如何进行实测数据与模型输出结果的拟合对比。

晏长街的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

根据身份证号获取出生日期,年龄,性别

java语言,根据身份证号获取出生日期,年龄,性别 // 测试程序 public class TestUtils { public static void main(String[] args) { String idcard = "xxxxxxxxxxxxxxxxxx";// 不方便透露的身份证号码 String birthday = IDCardUtils.getBirthday(idcard); int age = IDCardUtils.get

geaosu的博客 5880

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

JAVA中 根据身份证号获取用户年龄

思路:1.先验证身份证号是否正确 2.截取身份证号中个人出生的年月日 3.当前时间-出生时间=年龄 1.IdCardUtil:身份验证的工具类 package www.cfyg.com; import java.text.ParseException; import java.text.SimpleDateFormat; import ...

懒惰的小妖 6615

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

JAVA通过身份证号码获取出生年月、年龄及性别

import org.apache.commons.lang.StringUtils; import java.text.SimpleDateFormat; import java.util.Date; /** * @Description:身份证号的util * @Author: * @Date: Created in 11:26 2019-03-27 * @Modified By: ...

蓝色格子ren的博客 1万+

java代码实现根据身份证号获取性别,年龄

这里写自定义目录标题 // 根据身份编号获取性别 public static String getGenderByIdCard(String idCard) { String sGender = "未知"; String sCardNum = idCard.substring(16, 17); if (Integer.parseInt(sCardNum) % 2 != 0) { sGender = "男"; }

Q_Q104926的博客 2701

Java 根据身份证号获取年龄、性别、判断身份证号正确性

import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import com.suxsoft.esclient.pojo.Ret; public class IdCardManageUtil { fin...

weixin_40989555的博客 3509

Java根据身份证号获取生日、年龄、性别以及籍贯的工具类

Java根据身份证号获取生日、年龄、性别以及籍贯的工具类 参考 java8 通过18位身份证号提取用户信息(年龄,生日,姓别) 在java中实现通过身份证号码判断籍贯的小工具类 具体代码 import org.apache.commons.lang3.StringUtils; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import

weixin_44324815的博客 5120

java 根据身份证号码获取出生日期、性别、年龄

1.情景展示   如何根据身份证号,计算出出生日期、性别、年龄? 2.解决方案   从网上找的别人的,因为并没有实际用到,所以并未对其优化! /** * 通过身份证号码获取出生日期、性别、年龄 * @param certificateNo * @return 返回的出生日期格式:1990-01-01 性别格式:F-女,M-男 */ public static...

weixin_30437337的博客 3237

根据身份证号判断性别、年龄、生日

根据身份证号判断证件持有人的性别、年龄、生日。废话不多说,直接上代码。 package com.study.util; import java.text.SimpleDateFormat; import java.util.Date; import org.apache.log4j.Logger; /** * 15位长度的身份证号 * 1-2位:省、自治区、直辖市代...

MNONOO的博客 3176

根据身份证号码计算年龄和判断性别

/** * @author zhoufu * @Description 根据身份证号码计算年龄工具类 不考虑身份证有效问题 */ public class IdCardUtils { /** * 根据身份证号码计算年龄 * @param idCard * @return */ public static Object get...

qq_35501880的博客 791

根据身份证号进行推算用户生日、年龄、性别

项目中用户上传身份号,后端根据身份证号推算出用户生日、年龄、性别,代码如下: public class IdCardUtil { /** * 通过身份证号码获取出生日期、性别、年龄 * @param certificateNo * @return 返回的出生日期格式:1990-01-01 性别格式:F-女,M-男 */ public static Map<String, String> getBirAgeSex(String cert

qq_22744093的博客 1093
上一篇: JAVA反射中的getFields()方法和getDeclaredFields ()方法
下一篇: Java冻结Excel行或列
TARS_
博客等级 码龄6年 5粉丝 43原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值