Reputation: 52
I`m new to Vaadin. In my project I have a grid that was set editable, when I double click on grid, editing is enabled.
In my grid when editing was enabled, in the grid the datefield
set as an editable field.
I was using grid.setEditedField(editableField)
but it was throwing an error.
gridAssetDetail.getColumn("assignDate").setEditorField(getDateField());
private Field<?> getDateField() {
DateField editDate = new DateField();
editDate.setDateFormat("dd/MM/yyyy");
return editDate;
}
That way, the String format does not change to datefield.
Error:
Caused by: com.vaadin.data.util.converter.Converter$ConversionException:
Could not convert '07/04/1914' to java.util.Date
Upvotes: 0
Views: 546
Reputation: 6746
It seems that your error is due to the conversion from String
to Date
.
For converting a String
to a Date
you have to use a DateFormat
String string = "07/04/1914";
DateFormat format = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH);
Date date = format.parse(string);
System.out.println(date);
Or in short:
Date date = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH).parse("07/04/1914");
Source: Java string to date conversion
Upvotes: 1