protected Calendar firstIntervalDate( DateIntervalType intervalType, Date minDate, ColumnGroup columnGroup) { Calendar c = GregorianCalendar.getInstance(); c.setLenient(false); c.setTime(minDate); if (YEAR.equals(intervalType)) { c.set(Calendar.MONTH, 0); c.set(Calendar.DAY_OF_MONTH, 1); c.set(Calendar.HOUR, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); } if (QUARTER.equals(intervalType)) { int currentMonth = c.get(Calendar.MONTH); int firstMonthYear = columnGroup.getFirstMonthOfYear().getIndex(); int rest = Quarter.getPositionInQuarter(firstMonthYear, currentMonth + 1); c.add(Calendar.MONTH, rest * -1); c.set(Calendar.DAY_OF_MONTH, 1); c.set(Calendar.HOUR, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); } if (MONTH.equals(intervalType)) { c.set(Calendar.DAY_OF_MONTH, 1); c.set(Calendar.HOUR, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); } if (DAY.equals(intervalType) || DAY_OF_WEEK.equals(intervalType) || WEEK.equals(intervalType)) { c.set(Calendar.HOUR, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); } if (HOUR.equals(intervalType)) { c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); } if (MINUTE.equals(intervalType)) { c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); } if (SECOND.equals(intervalType)) { c.set(Calendar.MILLISECOND, 0); } return c; }