我有两个实体:
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;
}
现在我想“ List<Entry> entries
”生成新列表“ List<GroupedEntryByWeek> groupedEntries
”
我想创建一个函数:
public List<GroupedEntryByWeek> groupEntries(List<Entry> entries) {
List<GroupedEntryByWeek> groupedEntries;
// code for grouping
return groupedEntries;
}
这将返回我一个分组列表
Ungrouped list :
id amount date
1 500 9th june in millies
2 600 8th june in millies
3 700 1st june in millies
分组列表应如下所示:
id amount startdate enddate
1 700 28May 3June
2 1100 4june 9june