private DateCell getCell(Date d) { int index = CalendarUtil.getDaysBetween(firstDisplayed, d); if (index < 0 || grid.getNumCells() <= index) { return null; } DateCell cell = (DateCell) grid.getCell(index); if (cell.getValue().getDate() != d.getDate()) { throw new IllegalStateException(d + " cannot be associated with cell " + cell + " as it has date " + cell.getValue()); } return cell; } }
@SuppressWarnings("deprecation") private static DateRange getDateRangeStartingOnMonday(Date dateWithinTheWeek, int nrOfDaysTotal) { Date startDate = new Date(dateWithinTheWeek.getTime()); int day = startDate.getDay() - 1; int daysAfterMonday = day; if (day == -1) { // corner case when the date within the week in Sunday and thus getDay() == 0 (and day == -1), so we need Monday // from that week, which is 6 days back daysAfterMonday = 6; } CalendarUtil.addDaysToDate(startDate, -daysAfterMonday); Date endDate = new Date(startDate.getTime()); CalendarUtil.addDaysToDate(endDate, nrOfDaysTotal - 1); return new DateRange(startDate, endDate, CalendarUtil.getDaysBetween(startDate, endDate)); }
/** * 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)); }
private DateCell getCell(Date d) { int index = CalendarUtil.getDaysBetween(firstDisplayed, d); if (index < 0 || grid.getNumCells() <= index) { return null; } DateCell cell = (DateCell) grid.getCell(index); if (cell.getValue().getDate() != d.getDate()) { throw new IllegalStateException(d + " cannot be associated with cell " + cell + " as it has date " + cell.getValue()); } return cell; } }
private DateCell getCell(Date d) { int index = CalendarUtil.getDaysBetween(firstDisplayed, d); if (index < 0 || grid.getNumCells() <= index) { return null; } DateCell cell = (DateCell) grid.getCell(index); if (cell.getValue().getDate() != d.getDate()) { throw new IllegalStateException(d + " cannot be associated with cell " + cell + " as it has date " + cell.getValue()); } return cell; } }
lastYear.setDate(31); retVal = String.valueOf(padInt(CalendarUtil.getDaysBetween(lastYear, date), 3)); break; case 'z':
lastYear.setDate(31); retVal = String.valueOf(padInt(CalendarUtil.getDaysBetween(lastYear, date), 3)); break; case 'z':