Date startDateFilter, Date endDateFilter) {
List<LoadPeriod> list = new PeriodsBuilder(factory, sortedByStartDate).buildPeriods();
List<LoadPeriod> toReturn = new ArrayList<LoadPeriod>();
for (LoadPeriod loadPeriod : list) {
final GanttDate finalStartDate;
if (startDateFilter != null) {
finalStartDate = GanttDate.max(GanttDate
.createFrom(new LocalDate(startDateFilter.getTime())),
loadPeriod.getStart());
} else {
finalStartDate = loadPeriod.getStart();
}
final GanttDate finalEndDate;
if (endDateFilter != null) {
finalEndDate = GanttDate.min(loadPeriod.getEnd(), GanttDate
.createFrom(new LocalDate(endDateFilter.getTime())));
} else {
finalEndDate = loadPeriod.getEnd();