How to display only years and months without days in a pop-up window in Vaadin datepicker?

Issue

How to display only years and months without days in a pop-up window in Vaadin datepicker?
Is there such a possibility?
See the example in the screenshot

Solution

DatePicker doesn’t have that kind of functionality, at least at the moment. Probably the easiest way to implement a popup for a year and a month would be a Dialog with two Select components.

        Dialog dialog = new Dialog();
        List<String> collect = IntStream.rangeClosed(2000, 2022).boxed()
                .map(integer -> integer.toString()).collect(Collectors.toList());
        Select<String> yearSelect = new Select<String>(collect.toArray(new String[0]));
        Select<String> monthSelect = new Select<>("Jan", "Feb", "...");
        dialog.add(yearSelect, monthSelect);
        dialog.open();

Answered By – ollitietavainen

Answer Checked By – Candace Johnson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.