### Question:
DateUtils { public static float getAge(Date startDate, Date endDate) { Calendar start = Calendar.getInstance(); start.setTime(startDate); Calendar end = Calendar.getInstance(); end.setTime(endDate); return getAge(start, end); }  static String formatDate(Date date); static String formatCalendar2Day(Calendar calendar); static String formatDateTime(Date date); static String formatCalendar2Second(Calendar calendar); static String formatDateTime2Minute(Date date); static String formatCalendar2Minute(Calendar calendar); static String formatDateTime(Date date, String format); static String formatCalendar(Calendar calendar, String format); static int getHour(Date date); static int getMinute(Date date); static Calendar getCalendar(String dateTime); static Date getDate(String dateTime); static Date getDateEx(String dateTime); static Calendar getCalendarEx(String dateTime); static Calendar getFirstDayOfMonth(Calendar calendar); static Calendar getLastDayOfMonth(Calendar calendar); static void setToFirstDayOfMonth(Calendar calendar); static void setToLastDayOfMonth(Calendar calendar); static void setToZeroTime(Calendar calendar); @SuppressWarnings("deprecation") static void setToZeroTime(Date date); static void setToMaxTime(Calendar calendar); @SuppressWarnings("deprecation") static void setToMaxTime(Date date); static Date getZeroTimeDate(Date date); static Date getMaxTimeDate(Date date); static String getWasteTime(Date fromDate); static String getWasteTimeCN(Date fromDate); static String getWasteTime(Date startDate, Date endDate); static String getWasteTimeCN(Date startDate, Date endDate); static String getWasteTime(long wt); static String getWasteTimeCN(long wt); static float getAge(Date startDate, Date endDate); static float getAge(Calendar startDate, Calendar endDate); static float getAge(Calendar birthDate); static int[] getAgeDetail(Calendar startDate, Calendar endDate); static String getWeekCN(Calendar date); static Calendar getFirstDayOfNextMonth(Calendar calendar); static Calendar getLastDayOfNextMonth(Calendar calendar); static Calendar getDate4Range(Calendar calendar, String rangeConfig); static boolean isMonthEnd(Calendar calendar); static Map<String, String> dateFormats; }### Answer:
@Test public void testGetAge() throws ParseException { DecimalFormat f = new DecimalFormat("0.00"); Calendar startDate = DateUtils.getCalendar("2010-11-01"); Calendar endDate = DateUtils.getCalendar("2011-11-01"); Assert.assertEquals("1.00", f.format(DateUtils.getAge(startDate, endDate))); startDate = DateUtils.getCalendar("2010-10-01"); endDate = DateUtils.getCalendar("2011-12-01"); Assert.assertEquals("1.17", f.format(DateUtils.getAge(startDate, endDate))); }