title: Java 8 Streams Filter a list based on a condition
body: <p>I am trying to extract a filtered list on top of the original list based on some condition. I am using backport version of Java 8 and am not pretty sure how to do this.I get the Set from ccarReport.getCcarReportWorkflowInstances() call. I need to iterate and filter this set based on a condition match( I am comparing the date attribute in each object with the request date being passed. Below is the code</p>
  
  <pre><code>  Set&lt;CcarReportWorkflowInstance&gt; ccarReportWorkflowInstanceSet = ccarReport.getCcarReportWorkflowInstances();
    List&lt;CcarReportWorkflowInstance&gt; ccarReportWorkflowInstances = StreamSupport.stream(ccarReportWorkflowInstanceSet).filter(ccarReportWorkflowInstance -&gt; DateUtils.isSameDay(cobDate, ccarReportWorkflowInstance.getCobDate()));
  </code></pre>
  
  <p>The routine which is doing the job</p>
  
  <pre><code>  public List&lt;CcarRepWfInstDTO&gt; fetchReportInstances(Long reportId, Date cobDate) {
      List&lt;CcarRepWfInstDTO&gt; ccarRepWfInstDTOs = null;
      CcarReport ccarReport = validateInstanceSearchParams(reportId, cobDate);
      Set&lt;CcarReportWorkflowInstance&gt; ccarReportWorkflowInstanceSet = ccarReport.getCcarReportWorkflowInstances();
      List&lt;CcarReportWorkflowInstance&gt; ccarReportWorkflowInstances = StreamSupport.stream(ccarReportWorkflowInstanceSet).filter(ccarReportWorkflowInstance -&gt; DateUtils.isSameDay(cobDate, ccarReportWorkflowInstance.getCobDate()));
      ccarRepWfInstDTOs = ccarRepWfInstMapper.ccarRepWfInstsToCcarRepWfInstDTOs(ccarReportWorkflowInstances);
      return ccarRepWfInstDTOs;
  }
  </code></pre>
  
  <p>Error I get when I tried to use streams.</p>
  
  <p><a href="https://i.stack.imgur.com/2fUwH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2fUwH.jpg" alt="enter image description here"></a></p>