I ran into a strange problem with the DateTimePicker
component. I use a DateTimePicker
on a form and when the form is initialized for the first time and a value is set, the seconds and millisecond are chopped off and replaced with zeros. This only happens the first time; when the form is reused, the seconds and milliseconds are maintained.
I’ve tried to analyze the issue by adding debug info in the value change listener and discovered that right after initially setting the value (with the correct value), the value change listener is fired again, but now with the seconds and milliseconds chopped off. When reusing the form, the value changer is only fired once (to set the new form value). When pausing execution during the second value change event, you can actually see the DateTimePicker showing the correct value (with seconds and milliseconds).
I’ve tried various things to work around the issue (setting and resetting the value in the form constructor and when reusing the form, using and not using the binder), but it still chops the seconds and milliseconds. It is as if the precision (step value) is not correctly honored at first use.
I’m using Vaadin 14.3.0 with the DateTimePicker
configured as follows (in the form constructor):
creationTimestamp = new DateTimePicker("Created at");
creationTimestamp.setStep(Duration.ofMillis(1));
(the picker is actually bound to a Date
field – with an appropriate conversion – but as I’ve also tried not using the binder this shouldn’t be part of the issue)