### Question:
AgeUtils { public static int getFullAge(Date birthDate) { return getFullAge(birthDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); }  static int getFullAge(Date birthDate); static int getFullAge(Calendar birthDate); static int getFullAge(LocalDate birthDate); static int getFullAge(LocalDate fromDate, LocalDate toDate); static Period getAge(LocalDate birthDate); static Period getAge(LocalDate fromDate, LocalDate toDate);  }### Answer:
@Test public void testGetFullAge4LocalDateDetails() { int year = 2010; for (int m = 1; m <= 12; m++) { Assert.assertEquals(0, AgeUtils.getFullAge(LocalDate.of(year, 1, 1), LocalDate.of(year, m, 1))); } LocalDate toDate; int lastDay; for (int m = 1; m <= 12; m++) { toDate = LocalDate.of(year + 1, m, 1); lastDay = toDate.plusMonths(1).minusDays(1).getDayOfMonth(); for (int d = 1; d <= lastDay; d++) { Assert.assertEquals(1, AgeUtils.getFullAge(LocalDate.of(year, 1, 1), LocalDate.of(year + 1, m, d))); } } Assert.assertEquals(2, AgeUtils.getFullAge(LocalDate.of(year, 1, 1), LocalDate.of(year + 2, 1, 1))); Assert.assertEquals(2, AgeUtils.getFullAge(LocalDate.of(year, 2, 10), LocalDate.of(year + 2, 2, 10))); Assert.assertEquals(2, AgeUtils.getFullAge(LocalDate.of(year, 2, 10), LocalDate.of(year + 2, 12, 31))); Assert.assertEquals(1, AgeUtils.getFullAge(LocalDate.of(year, 2, 10), LocalDate.of(year + 2, 2, 9))); }
@Test public void testGetFullAge4LocalDate() { int currentYear = LocalDate.now().getYear(); int birthYear = 2010; LocalDate birthDate = LocalDate.of(birthYear, 1, 1); Assert.assertEquals(currentYear - birthYear, AgeUtils.getFullAge(birthDate)); }
@Test public void tesFullAge4Calendar() { Calendar birthDate = Calendar.getInstance(); int currentYear = birthDate.get(Calendar.YEAR); int birthYear = 2010; birthDate.set(Calendar.YEAR, birthYear); birthDate.set(Calendar.MONTH, 0); birthDate.set(Calendar.DATE, 1); Assert.assertEquals(currentYear - birthYear, AgeUtils.getFullAge(birthDate)); }
@Test public void tesFullAge4Date() { Calendar birthDate = Calendar.getInstance(); int currentYear = birthDate.get(Calendar.YEAR); int birthYear = 2010; birthDate.set(Calendar.YEAR, birthYear); birthDate.set(Calendar.MONTH, 0); birthDate.set(Calendar.DATE, 1); Assert.assertEquals(currentYear - birthYear, AgeUtils.getFullAge(birthDate.getTime())); }