/** * Shifts the currently specified date by the given number of months. The day * of the month will be pinned to the original value as far as possible. * * @param deltaMonths - number of months to be added to the current date */ public void shiftCurrentMonth(int deltaMonths) { CalendarUtil.addMonthsToDate(currentMonth, deltaMonths); refresh(); }
/** * Shifts the currently specified date by the given number of months. The day * of the month will be pinned to the original value as far as possible. * * @param deltaMonths - number of months to be added to the current date */ public void shiftCurrentMonth(int deltaMonths) { CalendarUtil.addMonthsToDate(currentMonth, deltaMonths); refresh(); }
/** * Shifts the currently specified date by the given number of months. The day * of the month will be pinned to the original value as far as possible. * * @param deltaMonths - number of months to be added to the current date */ public void shiftCurrentMonth(int deltaMonths) { CalendarUtil.addMonthsToDate(currentMonth, deltaMonths); refresh(); }
@SuppressWarnings("deprecation") public static Date getSameOrClosestDateInPreviousMonth(Date date) { Date desiredDate = new Date(date.getTime()); CalendarUtil.addMonthsToDate(desiredDate, -1); if (desiredDate.getMonth() == date.getMonth()) { // did not go one month back // e.g. 31 May -> 1st May, because April does not have 31st and thus the day is set to 1st May CalendarUtil.setToFirstDayOfMonth(desiredDate); CalendarUtil.addDaysToDate(desiredDate, -1); } return desiredDate; }
@SuppressWarnings("deprecation") public static Date getSameOrClosestDateInNextMonth(Date date) { Date desiredDate = new Date(date.getTime()); CalendarUtil.addMonthsToDate(desiredDate, 1); if (desiredDate.getMonth() > date.getMonth() + 1) { // skipped one month, e.g. 30 January -> 2nd (or 1st for leap-year) March, because February does not have 30th // set the date to last day of previous month CalendarUtil.setToFirstDayOfMonth(desiredDate); CalendarUtil.addDaysToDate(desiredDate, -1); } return desiredDate; }
private Date lastDayOfMonth(Date month) { Date lastDay = (Date) month.clone(); CalendarUtil.addMonthsToDate(lastDay, 1); CalendarUtil.setToFirstDayOfMonth(lastDay); CalendarUtil.addDaysToDate(lastDay, -1); return justDay(lastDay); }
/** * Returns a {@link DateRange} starting on first day of month in which the specified date is and ending on last day of that * month. * * @param date date from which to get the month date range * @return {@link DateRange} representing the month in which the specified date is */ @SuppressWarnings("deprecation") public static DateRange getMonthDateRange(Date date) { Date startDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(startDate); // the above method will set hours to 12 startDate.setHours(0); Date endDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(endDate); CalendarUtil.addMonthsToDate(endDate, 1); CalendarUtil.addDaysToDate(endDate, -1); endDate.setHours(0); return new DateRange(startDate, endDate, CalendarUtil.getDaysBetween(startDate, endDate)); }
break; case KeyCodes.KEY_PAGEUP: CalendarUtil.addMonthsToDate(this.cursor, -1); handleKey = true; break; case KeyCodes.KEY_PAGEDOWN: CalendarUtil.addMonthsToDate(this.cursor, 1); handleKey = true; break;
break; case KeyCodes.KEY_PAGEUP: CalendarUtil.addMonthsToDate(this.cursor, -1); handleKey = true; break; case KeyCodes.KEY_PAGEDOWN: CalendarUtil.addMonthsToDate(this.cursor, 1); handleKey = true; break;
CalendarUtil.addMonthsToDate(lastMonth, -1); this.pagePreviusMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT .format(lastMonth)); .format(this.today)); Date nextMonth = new Date(this.cursor.getTime()); CalendarUtil.addMonthsToDate(nextMonth, 1); this.pageNextMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT .format(nextMonth));
CalendarUtil.addMonthsToDate(lastMonth, -1); this.pagePreviusMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT .format(lastMonth)); .format(this.today)); Date nextMonth = new Date(this.cursor.getTime()); CalendarUtil.addMonthsToDate(nextMonth, 1); this.pageNextMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT .format(nextMonth));