java根据出生日期计算年龄

/**
  * @author jerry.chen
  * @param brithday
  * @return
  * @throws ParseException
  *             根据生日获取年龄;
  */
 public static int getCurrentAgeByBirthdate(String brithday)
   throws ParseException, Exception {
  try {
   Calendar calendar = Calendar.getInstance();
   SimpleDateFormat formatDate = new SimpleDateFormat(FORMATE_DATE_STR);
   String currentTime = formatDate.format(calendar.getTime());
   Date today = formatDate.parse(currentTime);
   Date brithDay = formatDate.parse(brithday);

   return today.getYear() - brithDay.getYear();
  } catch (Exception e) {
   return 0;
  }
 }
沉淀,是一种境界!
原文地址:https://www.cnblogs.com/java-chen/p/3141558.html