Vaadin 8 Grid Inline Edit with DateTimeField and SQL Timestamp

I am trying to implement this in my Grid:[code]
DateTimeField dateField = new DateTimeField();

Column<Sector, Timestamp> columnTimeStamp = addColumn(sector->sector.getDeparturetimetarget());

columnTimeStamp.setRenderer(time ->{
Instant instant = Instant.ofEpochMilli(time.getTime());
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);
return ldt;
},new LocalDateTimeRenderer());


[/code]The grid displays the data correctly, but when I double click for editing its show this error:

java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.time.temporal.Temporal at com.vaadin.ui.AbstractDateField.doSetValue([140:com.vaadin.server:8.1.1]

at com.vaadin.ui.AbstractField.setValue([140:com.vaadin.server:8.1.1]

at com.vaadin.ui.AbstractField.setValue([140:com.vaadin.server:8.1.1]

at java.lang.Iterable.forEach([:1.8.0_112]

at com.vaadin.ui.components.grid.EditorImpl.doEdit(
at com.vaadin.ui.components.grid.EditorImpl$1.bind(

What do I miss ?

Well, as the Stack Trace so kindly says, somewhere in your code you are trying to implicitly cast an object of type java.sql.Timestamp to java.time.temporal.Temporal. I would assume that this happens either in line 6 or 7 of the code you posted. A ClassCastException means that the types you are trying to convert from and to are incompatible for this operation. Casting is always only possible from a subclass to a superclass or superinterface, but never from a superclass or -interface to a subclass or -interface. It is neither possible to cast to a completely unrelated (in hierarchy tree) class/interface.

I have now a working solution, but i dont know if its the best way :

Column<Sector, Timestamp> columnTimeStamp = addColumn(
new ValueProvider<Sector, Timestamp>() { @Override public Timestamp apply(Sector sector) { return sector.getDeparturetimetarget(); } },
new ValueProvider<Timestamp, String>() { @Override public String apply(Timestamp timestamp) { String time = timestamp.toLocalDateTime().format(formatter).toString(); return time; } }


.withConverter(new LocalDateTimeToSqlTimestampConverter())

Is there a nicer solution?

Yes, the first argument in addColumn can be simplified to Sector::getDeparturetimetarget.