### Question:
TimelineUtilities { public static Map<Duration, List<DateDurationKey>> getTableOfLegalDates(TimeSpan span, Duration duration) { Map<Duration, List<DateDurationKey>> toReturn = new HashMap<>(); if (duration instanceof Months) { toReturn.putAll(createMonthDateEntries(span, duration)); } else if (duration instanceof Weeks) { createWeekDateEntries(span, toReturn, duration); } else if (duration instanceof Days) { createDayDateEntries(span, toReturn); } removeDayDuplicates(toReturn); return toReturn; } private  TimelineUtilities(); static void addDuration(Calendar calendar, Duration duration); static Calendar get0000(); static Calendar get0000(Date aDate); static List<TimeSpan> getIntervalsForSpan(Date startDate, TimeSpan span, int spanType); static Calendar getNext0000(Date aDate); static TimeSpan getPartialWeek(); static TimeSpan getPrecedingMonths(Date reference, int months, boolean includeThisMonth); static TimeSpan getPrecedingMonths(int months, boolean includeThisMonth); static TimeSpan getPrecedingWeeks(Date reference, int numWeeks, boolean includeThisWeek); static TimeSpan getPrecedingWeeks(int numWeeks, boolean includeThisWeek); static Map<Duration, List<DateDurationKey>> getTableOfLegalDates(TimeSpan span, Duration duration); static TimeSpan getThisDay(Date time); static TimeSpan getThisMonth(Date time); static TimeSpan getThisWeek(Date time); static TimeSpan getToday(); static TimeSpan getYesterday(); static boolean isAt0000(Date aDate); static boolean isDayWeekMonth(TimeSpan span); static boolean isDay(TimeSpan span); static boolean isWeek(TimeSpan span); static boolean isMonth(TimeSpan span); static boolean isRounded(Date time, Duration duration); static Calendar roundDown(Date date, Duration interval); static Calendar roundUp(Date date, Duration interval); static TimeSpan scale(TimeSpan span, double factor);  }### Answer:
@Test public void testGetTableOfLegalDates() throws ParseException { Date start = getDate("2010-02-03 00:00:00.000"); Date end = getDate("2010-03-02 00:00:00.000"); TimeSpan span = TimeSpan.get(start, end); Map<Duration, List<DateDurationKey>> map = TimelineUtilities.getTableOfLegalDates(span, Months.ONE); List<DateDurationKey> actual = map.get(Months.ONE); Assert.assertEquals(2, actual.size()); Assert.assertEquals(getDate("2010-02-01 00:00:00.000"), actual.get(0).getStartDate()); Assert.assertEquals(getDate("2010-03-01 00:00:00.000"), actual.get(0).getEndDate()); Assert.assertEquals(Months.ONE, actual.get(0).getDuration()); Assert.assertEquals(getDate("2010-03-01 00:00:00.000"), actual.get(1).getStartDate()); Assert.assertEquals(getDate("2010-04-01 00:00:00.000"), actual.get(1).getEndDate()); Assert.assertEquals(Months.ONE, actual.get(1).getDuration()); actual = map.get(Weeks.ONE); actual = map.get(Days.ONE); Assert.assertEquals(63, actual.size()); long jan31 = getDate("2010-01-31 00:00:00.000").getTime(); for (int index = 0; index < 63; ++index) { Assert.assertEquals(jan31 + index * (long)Constants.MILLIS_PER_DAY, actual.get(index).getStartDate().getTime()); Assert.assertEquals(jan31 + (index + 1) * (long)Constants.MILLIS_PER_DAY, actual.get(index).getEndDate().getTime()); Assert.assertEquals(Days.ONE, actual.get(index).getDuration()); } }