0

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 
Márton
  • 105
  • 10
PONRAJ
  • 52
  • 9
  • Please post also the error – Paolo Forgia Aug 09 '16 at 13:36
  • gridAssetDetail.getColumn("assignDate").setEditorField(getDateField());private Field> getDateField() { DateField editDate = new DateField(); editDate.setDateFormat("dd/MM/yyyy"); return editDate; } – PONRAJ Aug 09 '16 at 13:50
  • That's not an error. Add to your question the error that throw when you use `grid.setEditedField(editableField)` – Paolo Forgia Aug 09 '16 at 13:52
  • Caused by: com.vaadin.data.util.converter.Converter$ConversionException: Could not convert '07/04/1914' to java.util.Date – PONRAJ Aug 10 '16 at 04:45

1 Answers1

1

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

Community
  • 1
  • 1
Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58