You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DateFieldMinResolution.java 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package com.vaadin.tests.components.datefield;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Calendar;
  4. import com.vaadin.shared.ui.datefield.Resolution;
  5. import com.vaadin.tests.components.TestBase;
  6. import com.vaadin.tests.components.TestDateField;
  7. import com.vaadin.ui.AbstractDateField;
  8. import com.vaadin.ui.InlineDateField;
  9. import com.vaadin.ui.Label;
  10. public class DateFieldMinResolution extends TestBase {
  11. @Override
  12. protected void setup() {
  13. final SimpleDateFormat dformat = new SimpleDateFormat(
  14. "dd/MM/yyyy HH:mm");
  15. Calendar cal = Calendar.getInstance();
  16. cal.set(2019, 1, 1, 1, 1);
  17. AbstractDateField df = new TestDateField("foo");
  18. df.setResolution(Resolution.MINUTE);
  19. df.setDateFormat(dformat.toPattern());
  20. df.setValue(cal.getTime());
  21. df.setImmediate(true);
  22. addComponent(df);
  23. final Label lbl = new Label(dformat.format(cal.getTime()));
  24. lbl.setCaption("Selected date");
  25. InlineDateField idf = new InlineDateField("bar");
  26. idf.setResolution(Resolution.MINUTE);
  27. idf.setDateFormat(dformat.toPattern());
  28. idf.setValue(cal.getTime());
  29. idf.setImmediate(true);
  30. idf.addValueChangeListener(
  31. event -> lbl.setValue(dformat.format(event.getValue())));
  32. addComponent(idf);
  33. addComponent(lbl);
  34. }
  35. @Override
  36. protected String getDescription() {
  37. return "When the time controls are visible the time should be directed directly to the textfield";
  38. }
  39. @Override
  40. protected Integer getTicketNumber() {
  41. return 5387;
  42. }
  43. }