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

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 1:[1]

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();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ollitietavainen