Directory

← Back

Year Month Calendar Add-on

Full year / month calendar for Vaadin 22+

Author

Contributors

Rating

This addon can display a whole year calendar in one component.

Features

  • Java API for applying CSS class names to specific dates
  • Selection listener
  • Responsive layout

Sample code

    YearCalendar calendar = new YearCalendar();

    calendar.setClassNameGenerator(date -> {
      if (TestUtils.isPublicHoliday(date)) {
        return "holiday";
      }
      if (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY) {
        return "weekend";
      }
      return null;
    });

    Span selectedDate = new Span();
    calendar.addDateSelectedListener(ev -> {
      selectedDate.setText("Selected date: " + ev.getDate());
    });

    Span instructions = new Span("Use arrow keys or Ctrl+arrow keys to move.");
    add(new HorizontalLayout(instructions, selectedDate), calendar);

Links

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Bug fixes:

  • Avoid timezone conversion that results in wrong date (#18).
Released
2022-08-17
Maturity
TESTED
License
Apache License 2.0

Compatibility

Framework
Vaadin 22
Vaadin 23
Vaadin 24 in 2.2.0
Browser
Firefox
Safari
Google Chrome
iOS Browser
Android Browser
Microsoft Edge
Online