Java – format date in function
•
Java
I tried to format the date in the function interface, but I don't know if it is possible
SimpleDateFormat dt1 = new SimpleDateFormat("ddmmyyyyy"); List<MenuPrice> menuPrices = findAll(restaurant); menuPrices.parallelStream() .collect(Collectors.groupingBy(dt1.format(MenuPrice::getUpdateDate)));
Solution
This is possible, but not a method reference:
Map<String,List<MenuPrice>> menuPrices.parallelStream() .collect(Collectors.groupingBy(m -> dt1.format(m.getUpdateDate())));
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码