Because you sort by date, I don't think you need to have the check !timeOfInstance.isAfter(maxTime)