Group a list weekly to a new list and sum one of its field?
<p>I have two entities :</p>

<pre><code>class Entry {
   long amount;
   long date; //date is stored in millis
   long id;
   //getter and setters
}

class GroupedEntryByWeek {
   long amount;
   long startDate; // start date of week
   long endDate; // end date of week
   long id;
}
</code></pre>

<p>Now I want to "<code>List&lt;Entry&gt; entries</code>" to generate new list "<code>List&lt;GroupedEntryByWeek&gt; groupedEntries</code>" </p>

<p>i want to create a funtion:</p>

<pre><code>public List&lt;GroupedEntryByWeek&gt; groupEntries(List&lt;Entry&gt; entries) {
   List&lt;GroupedEntryByWeek&gt; groupedEntries;
   // code for grouping         

   return groupedEntries;
}
</code></pre>

<p>which will return me a grouped list</p>

<pre><code>Ungrouped list :

id        amount       date
1          500         9th june in millies 
2          600         8th june in millies
3          700         1st june in millies
</code></pre>

<p>Grouped list should be like :</p>

<pre><code>    id        amount       startdate   enddate 
    1          700         28May       3June
    2          1100        4june       9june
</code></pre>
