From the flow grid tutorial I try to use this expression:
grid.addColumn(new LocalDateTimeRenderer<>(
Item::getPurchaseDate,
"dd/MM HH:mm:ss")
).setHeader("Purchase date and time");
AFAIK Item::getPurchaseDate has to be already a LocalDateTime object, but my item::getTime gives just a String, I tried to use the standard mechanisms to convert that String to LocalDateTime: LocalDateTime.parse(Item::getTime, formatter)
where .parse is complaining The method parse(CharSequence, DateTimeFormatter) in the type LocalDateTime is not applicable for the arguments (item::getTime, DateTimeFormatter). So I have tried Casting item::getTime to CharSequence:
grid.addColumn(new LocalDateTimeRenderer<>(
LocalDateTime.parse((CharSequence) Item::getTime, formatter),
"dd/MM HH:mm:ss")
).setHeader("Purchase date and time");
which leaves me with same error message as above:
Cannot infer type arguments for LocalDateTimeRenderer<>
In the case that you want to do a casting you must take into account a little how to access the properties of the object in the case of Item::getDate the properties of the objects of the entities cannot be observed, for this use Item → table. addColumn(new LocalDateRenderer<>(Item
→ item.getDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), “dd-MM-yyyy”)).setHeader(“DATE OF ANYTHING”);
I had this same problem when I was migrating an application from Vaadin 7 to Vaadin 24