Two questions about DateField

Hi!

I have the following DateField:


DateField dateDatum = new DateField();
  dateDatum.setDateFormat("yyyy.MM.dd");
  dateDatum.setWidth("105px");
  dateDatum.setHeight("-1px");
  dateDatum.setRequired(true);
  dateDatum.setImmediate(true);
  dateDatum.setResolution(4);
vertikalLayout.addComponent(dateDatum);
  1. I would like to INSERT a record into a MySQL database with the value of this. The MySQL table field type is: date. (2012-09-07). The SQL statement doesn’t work because the dateDatum.getValue = "Fri Sep 07 21:36:15 CEST 2012’. How can I get the value in the yyy-MM-dd format?

  2. How can I set that the user should not be able to write in the text box, you can only select a date?

Thanks!

No answer :frowning:

  1. Instead of removing timestamp from the date change the type of column of your table from Date to Datetime or Timestamp.
    OR
    You can set Temoral Type in your POJO as TemporalType.DATE.

  2. If u enter a text in your datefield, there will an automatic invocation of vaadin validation which says, “Date format not recognized”.

Thank you for your answer!