根据出生日期,计算年龄,精确到天
来源:互联网 发布:绩效工资表软件 编辑:程序博客网 时间:2024/05/16 15:41
public static int calcAge(String birthday) {
int iage = 0;
if (birthday != "" || birthday != null) {
int year = Integer.parseInt(birthday.substring(0, 4));
int month = Integer.parseInt(birthday.substring(5, 7));
int day = Integer.parseInt(birthday.substring(8,10));
Calendar birthDate = new GregorianCalendar(year, month, day);
Calendar today = Calendar.getInstance();
if (today.get(Calendar.YEAR) > birthDate.get(Calendar.YEAR)) {
iage = today.get(Calendar.YEAR) - birthDate.get(Calendar.YEAR) - 1;
if (today.get(Calendar.MONTH) + 1 > birthDate .get(Calendar.MONTH)) {
iage++;
} else if (today.get(Calendar.MONTH) + 1 == birthDate .get(Calendar.MONTH)) {
if (today.get(Calendar.DAY_OF_MONTH) >= birthDate .get(Calendar.DAY_OF_MONTH)) {
iage++;
}
}
}
return iage;
}
return 0;
}
int iage = 0;
if (birthday != "" || birthday != null) {
int year = Integer.parseInt(birthday.substring(0, 4));
int month = Integer.parseInt(birthday.substring(5, 7));
int day = Integer.parseInt(birthday.substring(8,10));
Calendar birthDate = new GregorianCalendar(year, month, day);
Calendar today = Calendar.getInstance();
if (today.get(Calendar.YEAR) > birthDate.get(Calendar.YEAR)) {
iage = today.get(Calendar.YEAR) - birthDate.get(Calendar.YEAR) - 1;
if (today.get(Calendar.MONTH) + 1 > birthDate .get(Calendar.MONTH)) {
iage++;
} else if (today.get(Calendar.MONTH) + 1 == birthDate .get(Calendar.MONTH)) {
if (today.get(Calendar.DAY_OF_MONTH) >= birthDate .get(Calendar.DAY_OF_MONTH)) {
iage++;
}
}
}
return iage;
}
return 0;
}
0 0
- 根据出生日期,计算年龄,精确到天
- 根据出生日期计算年龄(精确到天)
- oracle 根据出生日期计算精确年龄
- 根据出生日期计算年龄
- 根据出生日期计算年龄
- 数据库里怎样根据出生日期计算精确年龄
- sql 根据出生日期计算年龄
- mysql根据出生日期计算年龄
- oracle根据出生日期计算年龄
- 根据出生日期Date 计算年龄
- java根据出生日期计算年龄
- mssql 根据出生日期计算年龄
- sqlserver输入出生日期返回年龄精确到天函数
- T-SQL 2 Tips: 1.计算任意两日期之间的"周一"到"周日"分别各有几个! 2.根据出生日期计算精确年龄!
- T-SQL 2 Tips: 1.计算任意两日期之间的"周一"到"周日"分别各有几个! 2.根据出生日期计算精确年龄!
- Oracle中根据出生日期计算年龄
- JS中根据出生日期计算年龄
- 根据出生日期计算年龄的代码
- Do you want to view only the webpage content that was delivered securely?
- 【技术类】【ArcGIS对国产卫星的支持2:高分一号卫星】篇5、实时表观反射率产品生产
- 设计模式(23):适配器模式Adapter
- oracle错误代码大全(超详细) oracle错误代码大全(超详细)
- kettle操作HIVE,可以链接,但不能取数的问题
- 根据出生日期,计算年龄,精确到天
- Android应用开发之使用Socket进行大文件断点上传续传
- STM32F4的IO设置测试
- Android:实现类似RadioButton自动换行及单选效果
- Linux查看网络流量
- 笑笑自己,笑笑尘世百态
- Epoll模型
- 欲问尘中客,浮生能几年?
- 获取用户下的所有表名