Grouping objects by date: am I an idiot?
<p>I have a list of objects called Activity:</p>

<pre><code>class Activity {
   public Date activityDate;
   public double amount;
}
</code></pre>

<p>I want to iterate through List, group them by date and return a new list . Here's what I currently do:</p>

<pre><code>private List&lt;Activity&gt; groupToList(List&lt;Activity&gt; activityList) {
    SimpleDateFormatter sdf = new SimpleDateFormatter("YYYY-MM-DD");
    Map&lt;String,Activity&gt; groupMap = new HashMap&lt;String,Activity&gt;();
    for (Activity a in activityList) {
        String key = sdf.format(a.getActivityDate());
        Activity group = groupMap.get(key);
        if (group == null) {
          group = new Activity();
          groupMap.add(key, group);
        }
        group.setAmount(group.getAmount() + a.getAmount());
    }
    return new ArrayList&lt;Activity&gt;(groupMap.values()); 
}
</code></pre>

<p>Is it a WTF to use the DateFormatter in this way? </p>

<ul>
<li>I'm using the DateFormatter because each activityDate could have time information.</li>
</ul>
