可能重复:
How can I calculate the age of a person in year, month, days?
How can I calculate the difference between two dates我如何计算死亡时的年龄?
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
if(petDetails.getDateOfDeath() != null){
String formatedDateOfDeath = formatter.format(petDetails.getDateOfDeath());
String formateDateOfBirth = formatter.format(petDetails.getDateOfBirth());
}
我怎么能计算出死亡年龄从上面。我不想使用任何外部库
编辑:请看看我到目前为止。没有其他线程就像我的。他们中的大多数是关于从DOB到今天的日期,而不是我使用的格式。
可能重复的[我如何计算一个人在年,月,日的年龄?](http://stackoverflow.com/questions/453208/how-can-i-calculate-the-age-of -a人 - 在 - 年 - 月 - 日)。另见[这个答案](http://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c/11942#11942)。 – 2011-03-04 15:15:00
或http://stackoverflow.com/questions/1116123/how-do-i-calculate-someones-age-in-java – 2011-03-04 15:17:22
从一小时前他的上一个问题的可能重复:http://stackoverflow.com/questions/5194216 /如何计算两个日期之间的差异关闭 – Riggy 2011-03-04 15:17:25