calendar-component-addon/src/main/java/org/vaadin/addon/calendar/item/CalendarItem.java
public interface CalendarItem extends Serializable {

    /**
     * Gets start date of event.
     *
     * @return Start date.
     */
    ZonedDateTime getStart();

    /**
     * Get end date of event.
     *
     * @return End date;
     */
    ZonedDateTime getEnd();

    /**
     * Gets caption of event.
     *
     * @return Caption text
     */
    String getCaption();

    /**
     * Gets description of event. Shown as a tooltip over the event.
     *
     * @return Description text.
     */
    String getDescription();

    /**
     * <p>
     * Gets style name of event. In the client, style name will be set to the
     * event's element class name and can be styled by CSS
     * </p>
     * Styling example:</br>
     * <code>Java code: </br>
     * event.setStyleName("color1");
     * </br></br>
     * CSS:</br>
     * .v-calendar-event-color1 {</br>
     * &nbsp;&nbsp;&nbsp;background-color: #9effae;</br>}</code>
     *
     * @return Style name.
     */
    String getStyleName();

    /**
     * An all-day event typically does not occur at a specific time but targets
     * a whole day or days. The rendering of all-day items differs from normal
     * items.
     *
     * @return true if this event is an all-day event, (default)false otherwise
     */
    default boolean isAllDay() {
        return false;
    }

    /**
     * @return (default)true, if this item is moveable.
     */
    default boolean isMoveable() {
        return true;
    }

    /**
     * @return (default)true, if this item is resizeable.
     */
    default boolean isResizeable() {
        return true;
    }

    /**
     * @return (default)true, if this item is clickable.
     */
    default boolean isClickable() {
        return true;
    }

    /**
     * Get the time caption format. The default is only '%s'. The first placeholder is replaced with start time
     * and the second with end time.
     * @return @see {@link org.vaadin.addon.calendar.client.ui.schedule.CalendarItem}
     */
    default String getDateCaptionFormat() {return org.vaadin.addon.calendar.client.ui.schedule.CalendarItem.SINGLE_TIME;}
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/client/ui/schedule/CalTime.java
public class CalTime implements Serializable {

    public int h;
    public int m;
    public int s;

    public CalTime() { super(); }

    public CalTime(int hour, int minute, int second) {
        this.h = hour;
        this.m = minute;
        this.s = second;
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/ui/CalendarTargetDetails.java
@SuppressWarnings("serial")

public class CalendarTargetDetails extends TargetDetailsImpl {

    private boolean hasDropTime;

    public CalendarTargetDetails(Map<String, Object> rawDropData, DropTarget dropTarget) {
        super(rawDropData, dropTarget);
    }

    /**
     * @return true if {@link #getDropTime()} will return a date object with the
     *         time set to the start of the time slot where the drop happened
     */
    public boolean hasDropTime() {
        return hasDropTime;
    }

    /**
     * Does the dropped item have a time associated with it
     *
     * @param hasDropTime
     */
    public void setHasDropTime(boolean hasDropTime) {
        this.hasDropTime = hasDropTime;
    }

    /**
     * @return the date where the drop happened
     */
    public Date getDropTime() {
        if (hasDropTime) {
            return (Date) getData("dropTime");
        } else {
            return (Date) getData("dropDay");
        }
    }

    /**
     * @return the {@link Calendar} instance which was the target of the drop
     */
    public Calendar getTargetCalendar() {
        return (Calendar) getTarget();
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/item/EditableCalendarItem.java
public interface EditableCalendarItem extends CalendarItem {

    /**
     * Set the visible text in the calendar for the event.
     *
     * @param caption
     *            The text to show in the calendar
     */
    void setCaption(String caption);

    /**
     * Set the description of the event. This is shown in the calendar when
     * hoovering over the event.
     *
     * @param description
     *            The text which describes the event
     */
    void setDescription(String description);

    /**
     * Set the end date of the event. Must be after the start date.
     *
     * @param end
     *            The end date to set
     */
    void setEnd(ZonedDateTime end);

    /**
     * Set the start date for the event. Must be before the end date
     *
     * @param start
     *            The start date of the event
     */
    void setStart(ZonedDateTime start);

    /**
     * Set the style name for the event used for styling the event cells
     *
     * @param styleName
     *            The stylename to use
     *
     */
    void setStyleName(String styleName);

    /**
     * Does the event span the whole day. If so then set this to true
     *
     * @param isAllDay
     *            True if the event spans the whole day. In this case the start
     *            and end times are ignored.
     */
    void setAllDay(boolean isAllDay);

    /**
     * Get a Notifier
     * @return Returns the Notifier for upadates
     */
    ItemChangeNotifier getNotifier();

    /**
     * Item to signal that an event has changed.
     */

    class ItemChangedEvent<EVENT extends EditableCalendarItem> implements Serializable {

        private EVENT source;

        public ItemChangedEvent(EVENT source) {
            this.source = source;
        }

        /**
         * @return the CalendarItem that has changed
         */
        public EVENT getCalendarEvent() {
            return source;
        }
    }

    /**
     * Listener for EventSetChange items.
     */

    interface ItemChangeListener extends Serializable {

        /**
         * Called when an Item has changed.
         */
        public void itemChanged(ItemChangedEvent itemChangedEvent);
    }

    /**
     * Notifier interface for EventChange items.
     */

    interface ItemChangeNotifier extends Serializable {

        /**
         * Add a listener to listen for EventChangeEvents. These items are
         * fired when a items properties are changed.
         *
         * @param listener
         *            The listener to add
         */
        void addListener(ItemChangeListener listener);

        /**
         * Remove a listener from the event provider.
         *
         * @param listener
         *            The listener to remove
         */
        void removeListener(ItemChangeListener listener);
    }

}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/handler/BasicItemMoveHandler.java
@SuppressWarnings("serial")

public class BasicItemMoveHandler implements CalendarComponentEvents.ItemMoveHandler {

    /*
     * (non-Javadoc)
     *
     * @see
     * org.vaadin.addon.calendar.ui.CalendarComponentEvents.ItemMoveHandler
     * #itemMove
     * (org.vaadin.addon.calendar.ui.CalendarComponentEvents.ItemMoveEvent)
     */
    @Override
    public void itemMove(CalendarComponentEvents.ItemMoveEvent event) {
        CalendarItem calendarItem = event.getCalendarItem();

        if (calendarItem instanceof EditableCalendarItem) {

            EditableCalendarItem editableItem = (EditableCalendarItem) calendarItem;

            ZonedDateTime newFromTime = event.getNewStart();

            long length = Duration.between(editableItem.getStart(), editableItem.getEnd()).toMillis();

            ZonedDateTime newEndTime = ZonedDateTime.from(newFromTime).plus(length, ChronoUnit.MILLIS);

            setDates(editableItem, newFromTime, newEndTime);
        }
    }

    /**
     * Set the start and end dates for the event
     *
     * @param event
     *            The event that the start and end dates should be set
     * @param start
     *            The start date
     * @param end
     *            The end date
     */
    protected void setDates(EditableCalendarItem event, ZonedDateTime start, ZonedDateTime end) {
        event.setStart(start);
        event.setEnd(end);
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/ui/CalendarDateRange.java
@SuppressWarnings("serial")

public class CalendarDateRange implements Serializable {

    private ZonedDateTime start;

    private ZonedDateTime end;

    /**
     * Constructor
     * @deprecated
     *
     * @param start
     *            The start date and time of the date range
     * @param end
     *            The end date and time of the date range
     */
    public CalendarDateRange(Date start, Date end, TimeZone tz) {
        this(ZonedDateTime.ofInstant(start.toInstant(), tz.toZoneId()),
                ZonedDateTime.ofInstant(end.toInstant(), tz.toZoneId()));
    }

    /**
     * Constructor
     *
     * @param start
     *            The start date and time of the date range
     * @param end
     *            The end date and time of the date range
     */
    public CalendarDateRange(ZonedDateTime start, ZonedDateTime end) {
        super();
        this.start = start;
        this.end = end;
    }

    /**
     * Get the start date of the date range
     *
     * @return the start Date of the range
     */
    public ZonedDateTime getStart() {
        return start;
    }

    /**
     * Get the end date of the date range
     *
     * @return the end Date of the range
     */
    public ZonedDateTime getEnd() {
        return end;
    }

    /**
     * Is a date in the date range
     *
     * @param date
     *            The date to check
     * @return true if the date range contains a date start and end of range
     *         inclusive; false otherwise
     */
    public boolean inRange(ZonedDateTime date) {
        if (date == null) {
            return false;
        }

        return date.compareTo(start) >= 0 && date.compareTo(end) <= 0;
    }

    /*
     * (non-Javadoc)
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "CalendarDateRange [start=" + start + ", end=" + end + "]";
    }

}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/client/CalendarServerRpc.java
public interface CalendarServerRpc extends ServerRpc {

    void itemMove(int itemIndex, CalDate date);

    void itemClick(int itemIndex);

    void itemResize(int itemIndex, CalDate newStartDate, CalDate newEndDate);

    void rangeSelect(SelectionRange dateSelectionRange);

    void forward();

    void backward();

    void dateClick(CalDate date);

    void weekClick(String eventValue);

    void actionOnEmptyCell(String actionKey, CalDate startDate, CalDate endDate);

    void actionOnItem(String actionKey, CalDate startDate, CalDate endDate, int itemIndex);

    @Delayed(lastOnly = true)
    void scroll(int scrollPosition);
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/client/ui/schedule/SelectionRange.java
public class SelectionRange implements Serializable {

    /**
     * start minutes
     */
    public int sMin = 0;

    /**
     * end minutes
     */
    public int eMin = 0;

    /**
     * start date
     */
    public CalDate s;

    /**
     * end date
     */
    public CalDate e;

    public SelectionRange() { super(); }

    public void setStartDay(CalDate startDay) {
        s = startDay;
    }

    public void setEndDay(CalDate endDay) {
        e = endDay;
    }

    public CalDate getStartDay() {
        return s;
    }

    public CalDate getEndDay() {
        return e;
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/ui/WeeklyCaptionProvider.java
@FunctionalInterface
public interface WeeklyCaptionProvider {

    String captionFrom(TemporalAccessor date);
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/handler/BasicDateClickHandler.java
@SuppressWarnings("serial")

public class BasicDateClickHandler implements CalendarComponentEvents.DateClickHandler {

    private boolean monthInCycle = true;

    public BasicDateClickHandler() {}

    public BasicDateClickHandler(boolean monthInCycle) {
        this.monthInCycle = monthInCycle;
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * org.vaadin.addon.calendar.ui.CalendarComponentEvents.DateClickHandler
     * #dateClick
     * (org.vaadin.addon.calendar.ui.CalendarComponentEvents.DateClickEvent)
     */
    @Override
    public void dateClick(CalendarComponentEvents.DateClickEvent event) {

        org.vaadin.addon.calendar.Calendar comp = event.getComponent();

        if (comp.isDayMode()) {

            switchToWeek(event);

        } else if (isMonthInCycle() && comp.isWeeklyMode()) {

            switchToMonth(event);

        } else {

            switchToDay(event);
        }
    }

    /**
     * Set the start and end dates for the event
     *
     * @param event
     *            The event that the start and end dates should be set
     * @param start
     *            The start date
     * @param end
     *            The end date
     */
    protected void setDates(CalendarComponentEvents.DateClickEvent event, ZonedDateTime start, ZonedDateTime end) {
        event.getComponent().setStartDate(start);
        event.getComponent().setEndDate(end);
    }

    public boolean isMonthInCycle() {
        return monthInCycle;
    }

    public void setMonthInCycle(boolean monthInCycle) {
        this.monthInCycle = monthInCycle;
    }


    /*
     * Switch modes
     */

    protected void switchToDay(CalendarComponentEvents.DateClickEvent event) {
        event.getComponent().withDay(event.getDate());
    }

    protected void switchToWeek(CalendarComponentEvents.DateClickEvent event) {
        event.getComponent().withWeek(event.getDate());
    }

    protected void switchToMonth(CalendarComponentEvents.DateClickEvent event) {
        event.getComponent().withMonth(event.getDate().getMonth());
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/item/BasicItemProvider.java
@SuppressWarnings("serial")

public class BasicItemProvider<ITEM extends BasicItem> implements
        CalendarEditableItemProvider<ITEM>,
        CalendarItemProvider.ItemSetChangedNotifier,
        EditableCalendarItem.ItemChangeListener {

    protected List<ITEM> itemList = new ArrayList<>();

    private List<ItemSetChangedListener> listeners = new ArrayList<>();

    /*
     * (non-Javadoc)
     *
     * @see
     * org.vaadin.addon.calendar.event.CalendarItemProvider#getItems(java.
     * util.Date, java.util.Date)
     */
    @Override
    public List<ITEM> getItems(ZonedDateTime startDate, ZonedDateTime endDate) {

        final long startRange = startDate.toEpochSecond();
        final long endRange = endDate.toEpochSecond();

        return itemList.parallelStream().filter(i -> {

            long itemStart = i.getStart().toEpochSecond();
            long itemEnd = i.getEnd().toEpochSecond();

            // Select only items that overlaps with startDate and endDate.

            return ((itemStart >= startRange && itemStart <= endRange)
                    || (itemEnd >= startRange && itemEnd <= endRange)
                    || (itemStart <= startRange && itemEnd >= endRange));

        }).collect(Collectors.toList());
    }

    /**
     * Does this event provider container this event
     *
     * @param item
     *            The event to check for
     * @return If this provider has the event then true is returned, else false
     */
    @SuppressWarnings("unused")
    public boolean containsEvent(ITEM item) {
        return itemList.contains(item);
    }

    /*
     * (non-Javadoc)
     *
     * @see org.vaadin.addon.calendar.ui.CalendarComponentEvents.
     * ItemSetChangedNotifier #addListener
     * (org.vaadin.addon.calendar.ui.CalendarComponentEvents.
     * ItemSetChangedListener )
     */
    @Override
    public void addItemSetChangedListener(ItemSetChangedListener listener) {
        listeners.add(listener);

    }

    /*
     * (non-Javadoc)
     *
     * @see org.vaadin.addon.calendar.ui.CalendarComponentEvents.
     * ItemSetChangedNotifier #removeListener
     * (org.vaadin.addon.calendar.ui.CalendarComponentEvents.
     * ItemSetChangedListener )
     */
    @Override
    public void removeItemSetChangedListener(ItemSetChangedListener listener) {
        listeners.remove(listener);
    }

    /**
     * Fires a eventsetchange event. The event is fired when either an event is
     * added or removed to the event provider
     */
    protected void fireItemSetChanged() {
        ItemSetChangedEvent<ITEM> changeEvent = new ItemSetChangedEvent<>(this);
        for (ItemSetChangedListener listener : listeners) {
            listener.itemSetChanged(changeEvent);
        }
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * org.vaadin.addon.calendar.ui.CalendarComponentEvents.ItemChangeListener
     * #itemChanged
     * (org.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChange)
     */
    @Override
    public void itemChanged(EditableCalendarItem.ItemChangedEvent changedEvent) {
        // naive implementation
        fireItemSetChanged();
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * org.vaadin.addon.calendar.event.CalendarEditableItemProvider#addItem
     * (org.vaadin.addon.calendar.event.CalendarItem)
     */
    @Override
    public void addItem(ITEM item) {
        itemList.add(item);

        item.getNotifier().addListener(this);

        fireItemSetChanged();
    }

    /*
         * (non-Javadoc)
         *
         * @see
         * org.vaadin.addon.calendar.event.CalendarEditableItemProvider#removeItem
         * (org.vaadin.addon.calendar.event.CalendarItem)
         */
    @Override
    public void removeItem(ITEM item) {
        itemList.remove(item);

        item.getNotifier().removeListener(this);

        fireItemSetChanged();
    }

    public void setItems(Collection<ITEM> items) {

        for (ITEM item : items) {
            itemList.add(item);
            item.getNotifier().addListener(this);
        }

        fireItemSetChanged();
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/client/ui/schedule/CalDate.java
public class CalDate implements Serializable {

    public int y;
    public int m;
    public int d;

    public CalTime t;

    public CalDate() { super(); }

    public CalDate(int year, int month, int day) {
        this.y = year;
        this.m = month;
        this.d = day;
    }

    public CalDate(int year, int month, int day, CalTime time) {
        this.y = year;
        this.m = month;
        this.d = day;
        this.t = time;
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/ui/CalendarComponentEvents.java
public interface CalendarComponentEvents extends Serializable {
    /**
     * Handler interface for day or time cell drag-marking with mouse.
     */

    interface RangeSelectNotifier extends Serializable {

        /**
         * Set the RangeSelectHandler that listens for drag-marking.
         *
         * @param listener
         *            RangeSelectHandler to be added.
         */
        Registration setHandler(RangeSelectHandler listener);
    }

    /**
     * RangeSelectEvent is sent when day or time cells are drag-marked with
     * mouse.
     */
    @SuppressWarnings("serial")
    class RangeSelectEvent extends CalendarComponentEvent {

        public static final String EVENT_ID = CalendarEventId.RANGESELECT;

        /** Calendar event's start date. */
        private ZonedDateTime start;

        /** Calendar event's end date. */
        private ZonedDateTime end;

        /**
         * RangeSelectEvent needs a start and end date.
         *
         * @param source
         *            Calendar component.
         * @param start
         *            Start date.
         * @param end
         *            End date.
         */
        public RangeSelectEvent(Calendar source, ZonedDateTime start, ZonedDateTime end) {
            super(source);
            this.start = start;
            this.end = end;
        }

        /**
         * Get start date.
         *
         * @return Start date.
         */
        public ZonedDateTime getStart() {
            return start;
        }

        /**
         * Get end date.
         *
         * @return End date.
         */
        public ZonedDateTime getEnd() {
            return end;
        }

    }

    /** RangeSelectHandler handles RangeSelectEvent. */
    interface RangeSelectHandler extends SerializableEventListener {

        /** Trigger method for the RangeSelectEvent. */
        Method rangeSelectMethod = ReflectTools.findMethod(
                RangeSelectHandler.class, "rangeSelect",
                RangeSelectEvent.class);

        /**
         * This method will be called when day or time cells are drag-marked
         * with mouse.
         *
         * @param event
         *            RangeSelectEvent that contains range start and end date.
         */
        void rangeSelect(RangeSelectEvent event);
    }

    /** Notifier interface for navigation listening. */
    interface NavigationNotifier extends Serializable {
        /**
         * Add a forward navigation listener.
         *
         * @param handler
         *            ForwardHandler to be added.
         */
        Registration setHandler(ForwardHandler handler);

        /**
         * Add a backward navigation listener.
         *
         * @param handler
         *            BackwardHandler to be added.
         */
        Registration setHandler(BackwardHandler handler);

        /**
         * Add a date click listener.
         *
         * @param handler
         *            DateClickHandler to be added.
         */
        Registration setHandler(DateClickHandler handler);

        /**
         * Add a item click listener.
         *
         * @param handler
         *            ItemClickHandler to be added.
         */
        Registration setHandler(ItemClickHandler handler);

        /**
         * Add a week click listener.
         *
         * @param handler
         *            WeekClickHandler to be added.
         */
        Registration setHandler(WeekClickHandler handler);
    }

    /**
     * ForwardEvent is sent when forward navigation button is clicked.
     */
    @SuppressWarnings("serial")
    class ForwardEvent extends CalendarComponentEvent {

        public static final String EVENT_ID = CalendarEventId.FORWARD;

        /**
         * ForwardEvent needs only the source component.
         *
         * @param source
         *            Calendar component.
         */
        public ForwardEvent(Calendar source) {
            super(source);
        }
    }

    /** ForwardHandler handles ForwardEvent. */
    interface ForwardHandler extends SerializableEventListener {

        /** Trigger method for the ForwardEvent. */
        Method forwardMethod = ReflectTools.findMethod(
                ForwardHandler.class, "forward", ForwardEvent.class);

        /**
         * This method will be called when date range is moved forward.
         *
         * @param event
         *            ForwardEvent
         */
        void forward(ForwardEvent event);
    }

    /**
     * BackwardEvent is sent when backward navigation button is clicked.
     */
    @SuppressWarnings("serial")
    class BackwardEvent extends CalendarComponentEvent {

        public static final String EVENT_ID = CalendarEventId.BACKWARD;

        /**
         * BackwardEvent needs only the source source component.
         *
         * @param source
         *            Calendar component.
         */
        public BackwardEvent(Calendar source) {
            super(source);
        }
    }

    /** BackwardHandler handles BackwardEvent. */
    interface BackwardHandler extends SerializableEventListener {

        /** Trigger method for the BackwardEvent. */
        Method backwardMethod = ReflectTools.findMethod(
                BackwardHandler.class, "backward", BackwardEvent.class);

        /**
         * This method will be called when date range is moved backwards.
         *
         * @param event
         *            BackwardEvent
         */
        void backward(BackwardEvent event);
    }

    /**
     * DateClickEvent is sent when a date is clicked.
     */
    @SuppressWarnings("serial")
    class DateClickEvent extends CalendarComponentEvent {

        public static final String EVENT_ID = CalendarEventId.DATECLICK;

        /** Date that was clicked. */
        private ZonedDateTime date;

        /** DateClickEvent needs the target date that was clicked. */
        public DateClickEvent(Calendar source, ZonedDateTime date) {
            super(source);
            this.date = date;
        }

        /**
         * Get clicked date.
         *
         * @return Clicked date.
         */
        public ZonedDateTime getDate() {
            return date;
        }
    }

    /** DateClickHandler handles DateClickEvent. */
    interface DateClickHandler extends SerializableEventListener {

        /** Trigger method for the DateClickEvent. */
        Method dateClickMethod = ReflectTools.findMethod(
                DateClickHandler.class, "dateClick", DateClickEvent.class);

        /**
         * This method will be called when a date is clicked.
         *
         * @param event
         *            DateClickEvent containing the target date.
         */
        void dateClick(DateClickEvent event);
    }

    /**
     * WeekClick is sent when week is clicked.
     */
    @SuppressWarnings("serial")
    class WeekClick extends CalendarComponentEvent {

        public static final String EVENT_ID = CalendarEventId.WEEKCLICK;

        /** Target week. */
        private int week;

        /** Target year. */
        private int year;

        /**
         * WeekClick needs a target year and week.
         *
         * @param source
         *            Target source.
         * @param week
         *            Target week.
         * @param year
         *            Target year.
         */
        public WeekClick(Calendar source, int week, int year) {
            super(source);
            this.week = week;
            this.year = year;
        }

        /**
         * Get week as a integer. See {@link java.util.Calendar} for the allowed
         * values.
         *
         * @return Week as a integer.
         */
        public int getWeek() {
            return week;
        }

        /**
         * Get year as a integer. See {@link java.util.Calendar} for the allowed
         * values.
         *
         * @return Year as a integer
         */
        public int getYear() {
            return year;
        }
    }

    /** WeekClickHandler handles WeekClicks. */
    interface WeekClickHandler extends SerializableEventListener {

        /** Trigger method for the WeekClick. */
        Method weekClickMethod = ReflectTools.findMethod(
                WeekClickHandler.class, "weekClick", WeekClick.class);

        /**
         * This method will be called when a week is clicked.
         *
         * @param event
         *            WeekClick containing the target week and year.
         */
        void weekClick(WeekClick event);
    }

    /**
     * ItemResizeEvent is sent when an item is resized
     */
    @SuppressWarnings("serial")
    class ItemResizeEvent extends CalendarComponentEvent {

        public static final String EVENT_ID = CalendarEventId.ITEM_RESIZE;

        private CalendarItem calendarItem;

        private ZonedDateTime startTime;

        private ZonedDateTime endTime;

        public ItemResizeEvent(Calendar source, CalendarItem calendarItem,
                               ZonedDateTime startTime, ZonedDateTime endTime) {
            super(source);
            this.calendarItem = calendarItem;
            this.startTime = startTime;
            this.endTime = endTime;
        }

        /**
         * Get target event.
         *
         * @return Target event.
         */
        public CalendarItem getCalendarItem() {
            return calendarItem;
        }

        /**
         * @deprecated Use {@link #getNewStart()} instead
         *
         * @return the new start time
         */
        public ZonedDateTime getNewStartTime() {
            return startTime;
        }

        /**
         * Returns the updated start date/time of the event
         *
         * @return The new date for the event
         */
        public ZonedDateTime getNewStart() {
            return startTime;
        }

        /**
         * @deprecated Use {@link #getNewEnd()} instead
         *
         * @return the new end time
         */
        public ZonedDateTime getNewEndTime() {
            return endTime;
        }

        /**
         * Returns the updates end date/time of the event
         *
         * @return The new date for the item
         */
        public ZonedDateTime getNewEnd() {
            return endTime;
        }
    }

    /**
     * Notifier interface for item resizing.
     */
    interface ItemResizeNotifier extends Serializable {

        /**
         * Set a ItemResizeHandler.
         *
         * @param handler
         *            ItemResizeHandler to be set
         */
        Registration setHandler(EventResizeHandler handler);
    }

    /**
     * Handler for ItemResizeEvent event.
     */
    interface EventResizeHandler extends SerializableEventListener {

        /** Trigger method for the ItemResizeEvent. */
        Method itemResizeMethod = ReflectTools.findMethod(
                EventResizeHandler.class, "itemResize", ItemResizeEvent.class);

        void itemResize(ItemResizeEvent event);
    }

    /**
     * Notifier interface for item drag & drops.
     */
    interface ItemMoveNotifier {

        /**
         * Set the ItemMoveHandler.
         *
         * @param listener
         *            ItemMoveHandler to be added
         */
        Registration setHandler(ItemMoveHandler listener);

    }

    /**
     * ItemMoveEvent is sent when existing item is dragged to a new position.
     */
    @SuppressWarnings("serial")
    class ItemMoveEvent extends CalendarComponentEvent {

        public static final String EVENT_ID = CalendarEventId.ITEM_MOVE;

        /** Index for the moved Schedule.Item. */
        private CalendarItem calendarItem;

        /** New starting date for the moved Calendar.Item. */
        private ZonedDateTime newStart;

        /**
         * ItemMoveEvent needs the target event and new start date.
         *
         * @param source
         *            Calendar component.
         * @param calendarItem
         *            Target event.
         * @param newStart
         *            Target event's new start date.
         */
        public ItemMoveEvent(Calendar source, CalendarItem calendarItem,
                             ZonedDateTime newStart) {
            super(source);

            this.calendarItem = calendarItem;
            this.newStart = newStart;
        }

        /**
         * Get target event.
         *
         * @return Target event.
         */
        public CalendarItem getCalendarItem() {
            return calendarItem;
        }

        /**
         * Get new start date.
         *
         * @return New start date.
         */
        public ZonedDateTime getNewStart() {
            return newStart;
        }
    }

    /**
     * Handler interface for when items are being dragged on the calendar     *
     */
    interface ItemMoveHandler extends SerializableEventListener {

        /** Trigger method for the ItemMoveEvent. */
        Method itemMoveMethod = ReflectTools.findMethod(
                ItemMoveHandler.class, "itemMove", ItemMoveEvent.class);

        /**
         * This method will be called when item has been moved to a new
         * position.
         *
         * @param event
         *            ItemMoveEvent containing specific information of the new
         *            position and target event.
         */
        void itemMove(ItemMoveEvent event);
    }

    /**
     * ItemClickEvent is sent when an item is clicked.
     */
    @SuppressWarnings("serial")
    class ItemClickEvent extends CalendarComponentEvent {

        public static final String EVENT_ID = CalendarEventId.ITEM_CLICK;

        /** Clicked source event. */
        private CalendarItem calendarItem;

        /** Target source event is needed for the ItemClickEvent. */
        public ItemClickEvent(Calendar source, CalendarItem calendarItem) {
            super(source);
            this.calendarItem = calendarItem;
        }

        /**
         * Get the clicked event.
         *
         * @return Clicked event.
         */
        public CalendarItem getCalendarItem() {
            return calendarItem;
        }
    }

    /**
     * ItemClickHandler handles ItemClickEvent.
     */
    interface ItemClickHandler extends SerializableEventListener {

        /** Trigger method for the ItemClickEvent. */
        Method itemClickMethod = ReflectTools.findMethod(
                ItemClickHandler.class, "itemClick", ItemClickEvent.class);

        /**
         * This method will be called when an item is clicked.
         *
         * @param event
         *            ItemClickEvent containing the target item.
         */
        void itemClick(ItemClickEvent event);
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/handler/BasicBackwardHandler.java
@SuppressWarnings("serial")

public class BasicBackwardHandler implements CalendarComponentEvents.BackwardHandler {

    /*
     * (non-Javadoc)
     *
     * @see
     * org.vaadin.addon.calendar.ui.CalendarComponentEvents.BackwardHandler#
     * backward
     * (org.vaadin.addon.calendar.ui.CalendarComponentEvents.BackwardEvent)
     */
    @Override
    public void backward(CalendarComponentEvents.BackwardEvent event) {

        int firstDay = event.getComponent().getFirstVisibleDayOfWeek();
        int lastDay = event.getComponent().getLastVisibleDayOfWeek();

        ZonedDateTime start = event.getComponent().getStartDate();
        ZonedDateTime end = event.getComponent().getEndDate();

        long durationInDays;

        // for week view durationInDays = 7, for day view durationInDays = 1
        if (event.getComponent().isDayMode()) { // day view
            durationInDays = 1;
        } else if (event.getComponent().isWeeklyMode()) {
            durationInDays = 7;
        } else {
            durationInDays = Duration.between(start, end).toDays() +1;
        }

        start = start.minus(durationInDays, ChronoUnit.DAYS);
        end = end.minus(durationInDays, ChronoUnit.DAYS);

        if (event.getComponent().isDayMode()) { // day view

            int dayOfWeek = start.get(ChronoField.DAY_OF_WEEK);

            ZonedDateTime newDate = start;
            while (!(firstDay <= dayOfWeek && dayOfWeek <= lastDay)) {

                newDate = newDate.minus(1, ChronoUnit.DAYS);

                dayOfWeek = newDate.get(ChronoField.DAY_OF_WEEK);
            }

            setDates(event, newDate, newDate);

            return;

        }

        if (durationInDays < 28) {
            setDates(event, start, end);
        } else {
            // go 7 days before and get the last day from month
            setDates(event, start.minus(7, ChronoUnit.DAYS).with(lastDayOfMonth()), end.with(lastDayOfMonth()));
        }
    }

    /**
     * Set the start and end dates for the event
     *
     * @param event
     *            The event that the start and end dates should be set
     * @param start
     *            The start date
     * @param end
     *            The end date
     */
    protected void setDates(CalendarComponentEvents.BackwardEvent event, ZonedDateTime start, ZonedDateTime end) {
        event.getComponent().setStartDate(start);
        event.getComponent().setEndDate(end);
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/item/CalendarItemProvider.java
@FunctionalInterface
public interface CalendarItemProvider<ITEM extends CalendarItem> extends Serializable {

    /**
     * <p>
     * Gets all available items in the target date range between startDate and
     * endDate. The Vaadin Calendar queries the items from the range that is
     * shown, which is not guaranteed to be the same as the date range that is
     * set.
     * </p>
     *
     * <p>
     * For example, if you set the date range to be monday 22.2.2010 - wednesday
     * 24.2.2010, the used Item Provider will be queried for items between
     * monday 22.2.2010 00:00 and sunday 28.2.2010 23:59. Generally you can
     * expect the date range to be expanded to whole days and whole weeks.
     * </p>
     *
     * @param startDate
     *            Start date
     * @param endDate
     *            End date
     * @return List of items
     */
    List<ITEM> getItems(ZonedDateTime startDate, ZonedDateTime endDate);

    /**
     * Item to signal that the set of items has changed and the calendar
     * should refresh its view from the CalendarItemProvider.
     *
     */
    @SuppressWarnings("serial")
    class ItemSetChangedEvent<EVENT extends CalendarItem> implements Serializable {

        private CalendarItemProvider<EVENT> source;

        public ItemSetChangedEvent(CalendarItemProvider<EVENT> source) {
            this.source = source;
        }

        /**
         * @return the CalendarItemProvider that has changed
         */
        public CalendarItemProvider<EVENT> getProvider() {
            return source;
        }
    }

    /**
     * Listener for EventSetChange items.
     */

    @FunctionalInterface
    interface ItemSetChangedListener extends Serializable {

        /**
         * Called when the set of Events has changed.
         */

        void itemSetChanged(ItemSetChangedEvent changeEvent);
    }

    /**
     * Notifier interface for EventSetChange items.
     */

    interface ItemSetChangedNotifier extends Serializable {

        /**
         * Add a listener for listening to when new items are adding or removed
         * from the event provider.
         *
         * @param listener
         *            The listener to add
         */
        void addItemSetChangedListener(ItemSetChangedListener listener);

        /**
         * Remove a listener which listens to {@link ItemSetChangedEvent}-items
         *
         * @param listener
         *            The listener to remove
         */
        void removeItemSetChangedListener(ItemSetChangedListener listener);
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/handler/BasicItemResizeHandler.java
@SuppressWarnings("serial")

public class BasicItemResizeHandler implements CalendarComponentEvents.EventResizeHandler {

    /*
     * (non-Javadoc)
     *
     * @see
     * org.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler
     * #itemResize
     * (org.vaadin.addon.calendar.ui.CalendarComponentEvents.ItemResizeEvent)
     */
    @Override
    public void itemResize(CalendarComponentEvents.ItemResizeEvent event) {
        CalendarItem calendarItem = event.getCalendarItem();

        if (calendarItem instanceof EditableCalendarItem) {
            ZonedDateTime newStartTime = event.getNewStart();
            ZonedDateTime newEndTime = event.getNewEnd();

            setDates((EditableCalendarItem) calendarItem, newStartTime, newEndTime);
        }
    }

    /**
     * Set the start and end dates for the event
     *
     * @param event
     *            The event that the start and end dates should be set
     * @param start
     *            The start date
     * @param end
     *            The end date
     */
    protected void setDates(EditableCalendarItem event, ZonedDateTime start, ZonedDateTime end) {
        event.setStart(start);
        event.setEnd(end);
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/ui/CalendarComponentEvent.java
@SuppressWarnings("serial")

public class CalendarComponentEvent extends Component.Event {

    /**
     * Set the source of the event
     *
     * @param source
     *            The source calendar
     *
     */
    public CalendarComponentEvent(Calendar source) {
        super(source);
    }

    /*
     * (non-Javadoc)
     *
     * @see com.vaadin.ui.Component.Item#getComponent()
     */
    @Override
    public Calendar getComponent() {
        return (Calendar) super.getComponent();
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/client/CalendarEventId.java
public class CalendarEventId implements Serializable {

    public static final String ITEM_MOVE = "itemMove";
    public static final String ITEM_RESIZE = "itemResize";
    public static final String ITEM_CLICK = "itemClick";
    public static final String RANGESELECT = "rangeSelect";
    public static final String FORWARD = "forward";
    public static final String BACKWARD = "backward";
    public static final String DATECLICK = "dateClick";
    public static final String WEEKCLICK = "weekClick";
    public static final String ACTION = "action";
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/client/DateConstants.java
@SuppressWarnings({"deprecation"})
public class DateConstants implements Serializable {

    public static final String TIME_FORMAT_PATTERN = "HH:mm:ss";
    public static final String DATE_FORMAT_PATTERN = "yyyy-MM-dd";
    public static final String ACTION_DATE_TIME_FORMAT_PATTERN = DATE_FORMAT_PATTERN + " " + TIME_FORMAT_PATTERN;

    public static final long MINUTEINMILLIS = 60 * 1000;
    public static final long HOURINMILLIS = 60 * MINUTEINMILLIS;
    public static final long DAYINMILLIS = 24 * HOURINMILLIS;
    public static final long WEEKINMILLIS = 7 * DAYINMILLIS;

    public static final int DAYINMINUTES = 24 * 60;
    public static final int HOURINMINUTES = 60;

    public static Date toClientDate(CalDate date) {
        return new Date(date.y -1900, date.m -1, date.d, 0, 0, 0);
    }

    public static Date toClientDateTime(CalDate date) {
        return new Date(date.y -1900, date.m -1, date.d, date.t.h, date.t.m, date.t.s);
    }

    public static CalDate toRPCDateTime(Date date) {
        return new CalDate(date.getYear() + 1900, date.getMonth() + 1, date.getDate(),
                new CalTime(date.getHours(), date.getMinutes(), date.getSeconds()));
    }

    public static CalDate toRPCDate(Date date) {
        return new CalDate(date.getYear() + 1900, date.getMonth() + 1, date.getDate());
    }

    public static CalDate toRPCDate(int year, int month, int day) {
        return new CalDate(year + 1900, month + 1, day);
    }

}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/client/CalendarState.java
public class CalendarState extends AbstractComponentState {

    public boolean format24H;
    public String[] dayNames;
    public String[] monthNames;
    public int firstVisibleDayOfWeek = 1;
    public int lastVisibleDayOfWeek = 7;
    public int firstHourOfDay = 0;
    public int lastHourOfDay = 23;
    public int firstDayOfWeek = 1;
    public int scroll = 0;
    public CalDate now;
    public List<Day> days;
    public List<Item> items;
    public List<Action> actions;
    public boolean itemCaptionAsHtml;

    public ItemSortOrder itemSortOrder = ItemSortOrder.DURATION_DESC;

    /**
     * Defines sort strategy for items in calendar month view and week view. In
     * month view items will be sorted from top to bottom using the order in
     * day cell. In week view items inside same day will be sorted from left to
     * right using the order if their intervals are overlapping.
     * <p>
     * <ul>
     * <li>{@code UNSORTED} means no sort. Events will be in the order provided
     * by com.vaadin.ui.components.calendar.event.CalendarItemProvider.
     * <li>{@code START_DATE_DESC} means descending sort by items start date
     * (earlier event are shown first).
     * <li>{@code DURATION_DESC} means descending sort by duration (longer event
     * are shown first).
     * <li>{@code START_DATE_ASC} means ascending sort by items start date
     * (later event are shown first).
     * <li>{@code DURATION_ASC} means ascending sort by duration (shorter event
     * are shown first).
     * 
     * </ul>
     */
    public enum ItemSortOrder {
        UNSORTED, START_DATE_DESC, START_DATE_ASC, DURATION_DESC, DURATION_ASC;
    }

    public static class Day implements java.io.Serializable {
        public CalDate date;
        public String localizedDateFormat;
        public int dayOfWeek;
        public int week;
        public int yearOfWeek;
        public Set<SlotStyle> slotStyles;
    }

    public static class SlotStyle implements Serializable {
        public long slotStart;
        public String styleName;
    }

    public static class Action implements java.io.Serializable {

        public String caption;
        public String iconKey;
        public String actionKey;
        public String startDate;
        public String endDate;
    }

    public static class Item implements java.io.Serializable {
        public int index;
        public String caption;
        public String dateFrom;
        public String dateTo;
        public String timeFrom;
        public String timeTo;
        public String styleName;
        public String description;
        public boolean allDay;
        public boolean moveable;
        public boolean resizeable;
        public boolean clickable;
        public String dateCaptionFormat;
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/handler/BasicForwardHandler.java
@SuppressWarnings("serial")
public class BasicForwardHandler implements CalendarComponentEvents.ForwardHandler {

    /*
     * (non-Javadoc)
     *
     * @see org.vaadin.addon.calendar.ui.CalendarComponentEvents.ForwardHandler#
     * forward
     * (org.vaadin.addon.calendar.ui.CalendarComponentEvents.ForwardEvent)
     */
    @Override
    public void forward(CalendarComponentEvents.ForwardEvent event) {

        int firstDay = event.getComponent().getFirstVisibleDayOfWeek();
        int lastDay = event.getComponent().getLastVisibleDayOfWeek();

        ZonedDateTime start = event.getComponent().getStartDate();
        ZonedDateTime end = event.getComponent().getEndDate();

        long durationInDays;

        // for week view durationInDays = 7, for day view durationInDays = 1
        if (event.getComponent().isDayMode()) { // day view
            durationInDays = 1;
        } else if (event.getComponent().isWeeklyMode()) {
            durationInDays = 7;
        } else {
            durationInDays = Duration.between(start, end).toDays() +1;
        }

        start = start.plus(durationInDays, ChronoUnit.DAYS);
        end = end.plus(durationInDays, ChronoUnit.DAYS);

        if (event.getComponent().isDayMode()) { // day view

            int dayOfWeek = start.get(ChronoField.DAY_OF_WEEK);

            ZonedDateTime newDate = start;
            while (!(firstDay <= dayOfWeek && dayOfWeek <= lastDay)) {

                newDate = newDate.plus(1, ChronoUnit.DAYS);

                dayOfWeek = newDate.get(ChronoField.DAY_OF_WEEK);
            }

            setDates(event, newDate, newDate);

            return;
        }

        if (durationInDays < 28) {
            setDates(event, start, end);
        } else {
            // go 7 days forth and get the first day from month
            setDates(event, start.with(firstDayOfMonth()), end.plus(7, ChronoUnit.DAYS).with(firstDayOfMonth()));
        }

    }

    /**
     * Set the start and end dates for the event
     *
     * @param event
     *            The event that the start and end dates should be set
     * @param start
     *            The start date
     * @param end
     *            The end date
     */
    protected void setDates(CalendarComponentEvents.ForwardEvent event, ZonedDateTime start, ZonedDateTime end) {
        event.getComponent().setStartDate(start);
        event.getComponent().setEndDate(end);
    }
}
calendar-component-addon/src/main/java/org/vaadin/addon/calendar/handler/BasicWeekClickHandler.java
@SuppressWarnings("serial")

public class BasicWeekClickHandler implements CalendarComponentEvents.WeekClickHandler {

    /*
     * (non-Javadoc)
     *
     * @see org.vaadin.addon.calendar.ui.CalendarComponentEvents.WeekClickHandler
     * #weekClick(org.vaadin.addon.calendar.ui.CalendarComponentEvents.WeekClick)
     */
    @Override
    public void weekClick(CalendarComponentEvents.WeekClick event) {

        int week = event.getWeek();
        int year = event.getYear();

        ZonedDateTime dateTime = ZonedDateTime.now(event.getComponent().getZoneId());
        // set correct year and month
        dateTime = dateTime.with(ChronoField.YEAR, year).with(ChronoField.ALIGNED_WEEK_OF_YEAR, week);

        setDates(event, dateTime.with(ChronoField.DAY_OF_WEEK, 1), dateTime.with(ChronoField.DAY_OF_WEEK, 7));
    }

    /**
     * Set the start and end dates for the event
     *
     * @param event
     *            The event that the start and end dates should be set
     * @param start
     *            The start date
     * @param end
     *            The end date
     */
    protected void setDates(CalendarComponentEvents.WeekClick event, ZonedDateTime start, ZonedDateTime end) {
        event.getComponent().setStartDate(start);
        event.getComponent().setEndDate(end);
    }

}


Question: import static java.time.DayOfWeek.MONDAY;
import static java.time.DayOfWeek.SUNDAY;
import static java.time.temporal.TemporalAdjusters.firstDayOfMonth;
import static java.time.temporal.TemporalAdjusters.lastDayOfMonth;
import java.lang.reflect.Method;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Month;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.time.temporal.WeekFields;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.logging.Logger;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
import org.vaadin.addon.calendar.client.CalendarEventId;
import org.vaadin.addon.calendar.client.CalendarServerRpc;
import org.vaadin.addon.calendar.client.CalendarState;
import org.vaadin.addon.calendar.client.DateConstants;
import org.vaadin.addon.calendar.client.ui.schedule.CalDate;
import org.vaadin.addon.calendar.client.ui.schedule.CalTime;
import org.vaadin.addon.calendar.client.ui.schedule.SelectionRange;
import org.vaadin.addon.calendar.handler.BasicBackwardHandler;
import org.vaadin.addon.calendar.handler.BasicDateClickHandler;
import org.vaadin.addon.calendar.handler.BasicForwardHandler;
import org.vaadin.addon.calendar.handler.BasicItemMoveHandler;
import org.vaadin.addon.calendar.handler.BasicItemResizeHandler;
import org.vaadin.addon.calendar.handler.BasicWeekClickHandler;
import org.vaadin.addon.calendar.item.BasicItemProvider;
import org.vaadin.addon.calendar.item.CalendarItem;
import org.vaadin.addon.calendar.item.CalendarItemProvider;
import org.vaadin.addon.calendar.item.EditableCalendarItem;
import org.vaadin.addon.calendar.ui.CalendarComponentEvent;
import org.vaadin.addon.calendar.ui.CalendarComponentEvents;
import org.vaadin.addon.calendar.ui.CalendarDateRange;
import org.vaadin.addon.calendar.ui.CalendarTargetDetails;
import org.vaadin.addon.calendar.ui.WeeklyCaptionProvider;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.SerializableEventListener;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.DropTarget;
import com.vaadin.event.dd.TargetDetails;
import com.vaadin.server.KeyMapper;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
/*
 * Copyright 2000-2016 Vaadin Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.vaadin.addon.calendar;





/**
 * <p>
 * Vaadin Calendar is for visualizing items in a calendar. Calendar items can
 * be visualized in the variable length view depending on the start and end
 * dates.
 * </p>
 *
 * <li>You can set the viewable date range with the {@link #setStartDate(ZonedDateTime)}
 * and {@link #setEndDate(ZonedDateTime)} methods. Calendar has a default date range of
 * one week</li>
 *
 * <li>Calendar has two kind of views: monthly and weekly view</li>
 *
 * <li>If date range is seven days or shorter, the weekly view is used.</li>
 *
 * <li>Calendar queries its items by using a {@link CalendarItemProvider}. By
 * default, a {@link BasicItemProvider} is used.</li>
 *
 * @since 7.1
 * @author Vaadin Ltd.
 *
 */
@SuppressWarnings({"serial","unused"})

public class Calendar<ITEM extends EditableCalendarItem> extends AbstractComponent implements
        CalendarComponentEvents.NavigationNotifier,
        CalendarComponentEvents.ItemMoveNotifier,
        CalendarComponentEvents.RangeSelectNotifier,
        CalendarComponentEvents.ItemResizeNotifier,
        CalendarItemProvider.ItemSetChangedListener,
        DropTarget,
        Action.Container
        //,LegacyComponent
        //,CalendarItemProvider<ITEM>
{

    /**
     * Calendar can use either 12 hours clock or 24 hours clock.
     */
    public enum TimeFormat {
        Format12H(), Format24H()
    }

    /** Defines currently active format for time. 12H/24H. */
    protected TimeFormat currentTimeFormat;

    /** Defines the component's active time zone. */
    protected ZoneId zoneId = ZoneId.systemDefault();

    /** Defines the calendar's date range starting point. */
    protected ZonedDateTime startDate = null;

    /** Defines the calendar's date range ending point. */
    protected ZonedDateTime endDate = null;

    /** Item provider. */
    private CalendarItemProvider<ITEM> calendarItemProvider;

    /**
     * Internal buffer for the items that are retrieved from the item provider.
     */
    protected List<? extends CalendarItem> items;


    /** Date format that will be used in the UIDL for dates. */
    private final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern(DateConstants.DATE_FORMAT_PATTERN);

    /** Time format that will be used in the UIDL for time. */
    protected final DateTimeFormatter ACTION_DATE_TIME_FORMAT = DateTimeFormatter.ofPattern(DateConstants.ACTION_DATE_TIME_FORMAT_PATTERN);

    /** Time format that will be used in the UIDL for time. */
    private DateTimeFormatter timeFormatter;

    /** Caption format provuder for the weekly view */
Answer:     private WeeklyCaptionProvider weeklyCaptionFormatProvider = date -> DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(getLocale()).format(date);