I am trying to format a date inside a Functional 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)));
What is T between date and time? The T is just a literal to separate the date from the time, and the Z means “zero hour offset” also known as “Zulu time” (UTC). If your strings always have a “Z” you can use: SimpleDateFormat format = new SimpleDateFormat( “yyyy-MM-dd'T'HH:mm:ss).
The most basic function we use while dealing with the dates is as. Date() function. This function allows us to create a date value (without time) in R programming. It allows the various input formats of the date value as well through the format = argument.
R provides several options for dealing with date and date/time data. The builtin as. Date function handles dates (without times); the contributed library chron handles dates and times, but does not control for time zones; and the POSIXct and POSIXlt classes allow for dates and times with control for time zones.
It's possible, but not with a method reference:
Map<String,List<MenuPrice>>
menuPrices.parallelStream()
.collect(Collectors.groupingBy(m -> dt1.format(m.getUpdateDate())));
You could create a method for that btw, to make things slightly more readable:
private static String formatUpdatedDate(MenuPrice menu){
return dt1.format(menu.getUpdatedDate());
}
And use it:
.collect(Collectors.groupingBy(YourClass::formatUpdatedDate)
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