I have this class:
public class MenuPrice {
private BigDecimal price;
private Date updateDate;
}
I want to group by Date,
List<MenuPrice> menuPrices = findAll(restaurant);
menuPrices
.parallelStream()
.collect(Collectors.groupingBy(MenuPrice::getUpdateDate()));
but I have a compilation error : Syntax error on token "::", invalid AssignmentOperator
This is a simple syntax problem you are having here:
.collect(Collectors.groupingBy(MenuPrice::getUpdateDate));
But, I've seen that in other questions you (ab)use parallel in streams. This is most probably never a good idea, as you usually require lots of data for parallel to have any relevance.
Than using java.util.Date raises questions too; it's a really old API... This is especially weird since you use java-8 for streaming, but it already comes with far better classes in the java.time package
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With