Example usage for com.vaadin.client DateTimeService getNumberOfDaysInMonth

List of usage examples for com.vaadin.client DateTimeService getNumberOfDaysInMonth

Introduction

In this page you can find the example usage for com.vaadin.client DateTimeService getNumberOfDaysInMonth.

Prototype

public static int getNumberOfDaysInMonth(Date date) 

Source Link

Usage

From source file:com.example.test.client.VMultiSelectCalendarWidget.java

License:Apache License

@Override
public String getSubPartName(com.google.gwt.user.client.Element subElement) {
    if (contains(daysTable, subElement)) {
        // Day, find out which dayOfMonth and use that as the identifier
        DayWidget day = WidgetUtil.findWidget(subElement, DayWidget.class);
        if (day != null) {
            Date date = day.getDate();
            int id = date.getDate();
            // Zero or negative ids map to days of the preceding month,
            // past-the-end-of-month ids to days of the following month
            if (date.getMonth() < displayedMonth.getMonth()) {
                id -= DateTimeService.getNumberOfDaysInMonth(date);
            } else if (date.getMonth() > displayedMonth.getMonth()) {
                id += DateTimeService.getNumberOfDaysInMonth(displayedMonth);
            }/*  ww  w . j a va2s.  c o  m*/
            return SUBPART_DAY + id;
        }
    } else if (getCellFormatter().getElement(0, 2).isOrHasChild(subElement)) {
        return SUBPART_MONTH_YEAR_HEADER;
    }

    return null;
}

From source file:com.example.test.client.VMultiSelectCalendarWidget.java

License:Apache License

public void setMonth(Date month) {
    if (!SharedUtil.equals(displayedMonth, month)) {
        rangeStart = new Date(month.getYear(), month.getMonth(), month.getDate());
        rangeEnd = new Date(month.getYear(), month.getMonth(), DateTimeService.getNumberOfDaysInMonth(month));
        displayedMonth = month;/*  w ww  .jav  a 2s .  c  o m*/
        if (initialRenderDone) {
            renderCalendar();
        }
    }
}