Patricio Jerí Patricio Jerí - 1 year ago 139
Java Question

Vaadin InlineDateFormat Resolution Steps

For Vaadin's server side InlineDateField, one can set the resolution to minutes like this:

timeField = new InlineDateField( caption );

How do you set the step, eg: I want to get minutes in 15 minute intervals as opposed to getting a full list of 60 minutes.

Answer Source

You can't do that with this component.

But you can use it with Resolution.DAY(default) and generate your own Combo boxes for hour and minute pickers.

Example component:

public class MyDatePicker extends VerticalLayout {

    private InlineDateField dateField;
    private NativeSelect hourPicker;
    private NativeSelect minutePicker;

    public MyDatePicker(String caption) {

        dateField = new InlineDateField(caption);
        hourPicker = new NativeSelect();
        minutePicker = new NativeSelect();

        HorizontalLayout hourLayout = new HorizontalLayout();
        Label colonLabel = new Label("<b>:</b>");
        hourLayout.addComponents(hourPicker, colonLabel, minutePicker);

        addComponents(dateField, hourLayout);
        setComponentAlignment(hourLayout, Alignment.MIDDLE_CENTER);


    private void setValues() {
        hourPicker.setContainerDataSource(new BeanItemContainer<>(String.class, new ArrayList<>(Arrays.asList("01", "02", "...", "24"))));
        minutePicker.setContainerDataSource(new BeanItemContainer<>(String.class, new ArrayList<>(Arrays.asList("00", "15", "30", "45"))));"01");"00");

    public Date getValue() {
        Date date = dateField.getValue();

        // set hour and minutes to date

        return date;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download