Here you can find the source of getAgeAt(final Date birthday, final Date date)
public static int getAgeAt(final Date birthday, final Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int getAgeAt(final Date birthday, final Date date) { if (birthday == null || date == null || date.compareTo(birthday) < 0) { return 0; }//from w ww.j a v a2 s . c om final Calendar cal = Calendar.getInstance(); cal.setTime(birthday); final int birthYear = cal.get(Calendar.YEAR); final int birthMonth = cal.get(Calendar.MONTH); final int birthDay = cal.get(Calendar.DAY_OF_MONTH); cal.setTime(date); final int year = cal.get(Calendar.YEAR); final int month = cal.get(Calendar.MONTH); final int day = cal.get(Calendar.DAY_OF_MONTH); int age = year - birthYear; if (month < birthMonth || (month == birthMonth && day < birthDay)) { age--; } return age; } }