复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13public Long dayYear( String brithday ) { //获取当前日期 Date nowDate = new Date(); String dateStr = new SimpleDateFormat("yyyy-MM-dd").format(nowDate); String date1 = dateStr.substring(0,4); String date2 = brithday.substring(0,4); // +1是算上了出生就算一岁 Integer age = Integer.parseInt(date1) - Integer.parseInt(date2) + 1; System.out.println("今年"+age+"岁"); return age.longValue(); }
最后
以上就是负责毛豆最近收集整理的关于两个日期相差多少年 (现在多少岁)的全部内容,更多相关两个日期相差多少年内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复