/** * @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; } }