Topic: 求助:身份证年龄提取,并按固定格式显示 |
Print this page |
1.求助:身份证年龄提取,并按固定格式显示 | Copy to clipboard |
Posted by: henbane Posted on: 2005-05-28 10:08 JSP里怎么实现啊?不知道用什么函数,晕 |
2.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: GWoo Posted on: 2005-05-30 16:48 substring()啦用,然后转换成int,并和通过系统当前时间获得的当前年份进行就可以得到拉 int born = (new Integer(idCardNum.substring(a,b))).intValue(); int age = java.util.Calendar.getInstance().YEAR - born |
3.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: henbane Posted on: 2005-05-31 11:53 GWOO兄,太感谢了. 谢谢 |
4.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: mhlovers Posted on: 2005-06-29 11:47 好好看看java的String类的文档! |
5.Re:求助:身份证年龄提取,并按固定格式显示 [Re: mhlovers] | Copy to clipboard |
Posted by: henbane Posted on: 2005-06-29 20:38 又有一个问题,那如何判断周岁呢? 上面的是判断虚岁可以 |
6.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: why Posted on: 2005-06-30 06:31 henbane wrote: What's the difference between 虚岁 and 周岁? |
7.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: henbane Posted on: 2005-06-30 18:52 楼上兄弟 虚岁和周岁有区别啊。 比如一个人 1977年8月1日出生 如果当前日期是2005年8月1日以后的,则周岁是29岁 如果当前日期是2005年7月31日之前的,则其周岁应该是28岁 我现在的问题就是要判断周岁。上面的程序只是简单的年份相减来求的年龄。 |
8.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: GWoo Posted on: 2005-07-01 11:20 还是用substring()提取身份证的出生月日,然后和8月1日比较,>=8月1日就加一就可以了啊 |
9.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: henbane Posted on: 2005-07-01 20:13 谢谢楼上兄弟一直大力帮忙,但小弟还有疑问 int born = (new Integer(idCardNum.substring(a,b))).intValue(); int age = java.util.Calendar.getInstance().YEAR - born 上面获取YEAR,现在要获取日期是用.DATE吗? 另外如果今天是2005-07-31 那减去1977-08-01 20050731-19770801=?? 烦劳兄弟能否再赐援手?感激! |
10.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: chengbd Posted on: 2005-07-03 16:01 不赞成楼上这位兄弟坐等别人“赐援手”,自己在网上搜索一下就行了嘛 |
11.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: chengbd Posted on: 2005-07-03 16:12 http://dev.csdn.net/article/11/11147.shtm http://dev.csdn.net/develop/article/11/11145.shtm 计算Java日期 |
12.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: henbane Posted on: 2005-07-04 14:09 斑竹,谢谢你的提醒。 但我真的网上找了很多资料了,但一直得不到答案,所以才来问的 你的连接,我看过了,但是还是搞不清楚啊。 能否请斑竹帮帮忙。 另外,斑竹也可以见我的帖子记录,我在提问的同时,也查阅过很多很多资料,也帮助别人解答我所知道的问题。如TOMCAT设置等 |
13.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: GWoo Posted on: 2005-07-06 17:28 其实有好多方法可以计算的,你用年份相减计算年龄,月份和日期只作比较用(可以分别比较月份和日期),比较的结果决定是否加一,另外,我的代码有错,例如获得月份和日期应该是这样: int date = java.util.Calendar.getInstance().get(java.util.Calendar.DATE); int month = java.util.Calendar.getInstance().get(java.util.Calendar.MONTH); |
14.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: GWoo Posted on: 2005-07-06 17:32 http://java.sun.com/j2se/1.4.2/docs/api/ 在这里找java.util.Calendar的说明吧,里面讲的很清楚,然后自己尝试一下就行。good luck... |
15.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: henbane Posted on: 2005-07-06 21:40 谢谢GWOO兄弟。 |
16.Re:求助:身份证年龄提取,并按固定格式显示 [Re: henbane] | Copy to clipboard |
Posted by: why Posted on: 2005-07-06 21:53 Java Cookbook Recipe 6.8 Difference Between Two Dates Problem You need to compute the difference between two dates. Solution Convert to Date objects if necessary, call their getTime( ) methods, and subtract. Format the result yourself. Discussion The API has no general mechanism for computing the difference between two dates. This is surprising, given how often it comes up in some types of commercial data processing. However, it's fairly simple to implement this yourself:
I'm editing this recipe in November of 2003; the 20th Century AD ended at the end of 2000, so the value should be about 3 11/12 years, and it is: > java DateDiff The 21st century (up to Tue Nov 25 09:20:15 EST 2003) is 1058 days old. > |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |