title: Grouping by maximum timestamp in an ArrayList for attributed ID
body: <p>I have an arraylist that consists of an object that consists of a number of ID's and it's attributed timestamps. There are multiple id's with different timestamps in the arraylist. i would like to get the maximum timestamp for each id. how can i go about doing this? </p>
  
  <p>I Created the following function for sorting: </p>
  
  <pre><code>public Map&lt;Integer,Date&gt; getMaximumDateForId(Session session) throws ParseException {
      Map&lt;Integer,Date&gt; mapIdDate = new HashMap&lt;Integer,Date&gt;();
      SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
  
      List&lt;CSVServiceBaseFormat&gt;  listOfRemovedEntitlements = getListOfServiceProviderId(session);
          for(CSVServiceBaseFormat record : listOfRemovedEntitlements){
              if(!mapIdDate.containsKey(record.getBbd_id())){
                      mapIdDate.put(Integer.parseInt(record.getBbd_id()),formatter.parse(record.getActivity_date()));
  
              }else{
                  if((mapIdDate.get(formatter.parse(record.getActivity_date()))).before(formatter.parse(record.getActivity_date()))){
                      mapIdDate.put(Integer.parseInt(record.getBbd_id()),formatter.parse(record.getActivity_date()));
                  }
              }
          }
          return mapIdDate;
  }
  </code></pre>