/** * {@inheritDoc} */ public final String toString() { final StringBuilder b = new StringBuilder(); for (final Iterator<Date> i = iterator(); i.hasNext();) { /* * if (type != null && Value.DATE.equals(type)) { * b.append(DateFormat.getInstance().format((Date) i.next())); } * else { b.append(DateTimeFormat.getInstance().format((Date) * i.next(), isUtc())); } */ b.append(i.next()); if (i.hasNext()) { b.append(','); } } return b.toString(); }
/** * {@inheritDoc} */ public final String toString() { final StringBuffer b = new StringBuffer(); for (final Iterator i = iterator(); i.hasNext();) { /* * if (type != null && Value.DATE.equals(type)) { * b.append(DateFormat.getInstance().format((Date) i.next())); } * else { b.append(DateTimeFormat.getInstance().format((Date) * i.next(), isUtc())); } */ b.append(i.next()); if (i.hasNext()) { b.append(','); } } return b.toString(); }
/** * {@inheritDoc} */ public final String toString() { final StringBuilder b = new StringBuilder(); for (final Iterator<Date> i = iterator(); i.hasNext();) { /* * if (type != null && Value.DATE.equals(type)) { * b.append(DateFormat.getInstance().format((Date) i.next())); } * else { b.append(DateTimeFormat.getInstance().format((Date) * i.next(), isUtc())); } */ b.append(i.next()); if (i.hasNext()) { b.append(','); } } return b.toString(); }
/** * Applies the specified timezone to all dates in the list. * All dates added to this list will also have this timezone * applied. * @param timeZone a timezone to apply to contained dates */ public final void setTimeZone(final TimeZone timeZone) { if (!Value.DATE.equals(type)) { for (final Iterator i = iterator(); i.hasNext();) { ((DateTime) i.next()).setTimeZone(timeZone); } } this.timeZone = timeZone; this.utc = false; }
/** * Sets whether this list is in UTC or local time format. * * @param utc * The utc to set. */ public final void setUtc(final boolean utc) { if (!Value.DATE.equals(type)) { for (final Iterator i = iterator(); i.hasNext();) { ((DateTime) i.next()).setUtc(utc); } } this.timeZone = null; this.utc = utc; }
/** * Constructs a new date list of the specified type containing * the dates in the specified list. * @param list a list of dates to include in the new list * @param type the type of the new list */ public DateList(final DateList list, final Value type) { if (!Value.DATE.equals(type) && !Value.DATE_TIME.equals(type)) { throw new IllegalArgumentException( "Type must be either DATE or DATE-TIME"); } this.type = type; if (Value.DATE.equals(type)) { for (final Iterator i = list.iterator(); i.hasNext();) { add(new Date((Date) i.next())); } } else { for (final Iterator i = list.iterator(); i.hasNext();) { add(new DateTime((Date) i.next())); } } }
/** * Applies BYSECOND rules specified in this Recur instance to the specified date list. If no BYSECOND rules are * specified the date list is returned unmodified. * @param dates * @return */ private DateList getSecondVariants(final DateList dates) { if (getSecondList().isEmpty()) { return dates; } final DateList secondlyDates = getDateListInstance(dates); for (final Iterator i = dates.iterator(); i.hasNext();) { final Date date = (Date) i.next(); final Calendar cal = getCalendarInstance(date, true); for (final Iterator j = getSecondList().iterator(); j.hasNext();) { final Integer second = (Integer) j.next(); cal.set(Calendar.SECOND, second.intValue()); secondlyDates.add(Dates.getInstance(cal.getTime(), secondlyDates.getType())); } } return secondlyDates; }
/** * Applies BYWEEKNO rules specified in this Recur instance to the specified date list. If no BYWEEKNO rules are * specified the date list is returned unmodified. * @param dates * @return */ private DateList getWeekNoVariants(final DateList dates) { if (getWeekNoList().isEmpty()) { return dates; } final DateList weekNoDates = getDateListInstance(dates); for (final Iterator i = dates.iterator(); i.hasNext();) { final Date date = (Date) i.next(); final Calendar cal = getCalendarInstance(date, true); for (final Iterator j = getWeekNoList().iterator(); j.hasNext();) { final Integer weekNo = (Integer) j.next(); cal.set(Calendar.WEEK_OF_YEAR, Dates.getAbsWeekNo(cal.getTime(), weekNo.intValue())); weekNoDates.add(Dates.getInstance(cal.getTime(), weekNoDates.getType())); } } return weekNoDates; }
/** * Applies BYYEARDAY rules specified in this Recur instance to the specified date list. If no BYYEARDAY rules are * specified the date list is returned unmodified. * @param dates * @return */ private DateList getYearDayVariants(final DateList dates) { if (getYearDayList().isEmpty()) { return dates; } final DateList yearDayDates = getDateListInstance(dates); for (final Iterator i = dates.iterator(); i.hasNext();) { final Date date = (Date) i.next(); final Calendar cal = getCalendarInstance(date, true); for (final Iterator j = getYearDayList().iterator(); j.hasNext();) { final Integer yearDay = (Integer) j.next(); cal.set(Calendar.DAY_OF_YEAR, Dates.getAbsYearDay(cal.getTime(), yearDay.intValue())); yearDayDates.add(Dates.getInstance(cal.getTime(), yearDayDates.getType())); } } return yearDayDates; }
/** * @param val * @return Collection * @throws Throwable */ public static Collection<BwDateTime> makeDateTimes(final DateListProperty val) throws Throwable { DateList dl = val.getDates(); TreeSet<BwDateTime> ts = new TreeSet<BwDateTime>(); Parameter par = getParameter(val, "VALUE"); boolean isDateType = (par != null) && (par.equals(Value.DATE)); String tzidval = null; Parameter tzid = getParameter(val, "TZID"); if (tzid != null) { tzidval = tzid.getValue(); } Iterator it = dl.iterator(); while (it.hasNext()) { Date dt = (Date)it.next(); ts.add(BwDateTime.makeBwDateTime(isDateType, dt.toString(), tzidval)); } return ts; }
/** * Applies BYHOUR rules specified in this Recur instance to the specified date list. If no BYHOUR rules are * specified the date list is returned unmodified. * @param dates * @return */ private DateList getHourVariants(final DateList dates) { if (getHourList().isEmpty()) { return dates; } final DateList hourlyDates = getDateListInstance(dates); for (final Iterator i = dates.iterator(); i.hasNext();) { final Date date = (Date) i.next(); final Calendar cal = getCalendarInstance(date, true); for (final Iterator j = getHourList().iterator(); j.hasNext();) { final Integer hour = (Integer) j.next(); cal.set(Calendar.HOUR_OF_DAY, hour.intValue()); hourlyDates.add(Dates.getInstance(cal.getTime(), hourlyDates.getType())); } } return hourlyDates; }
/** * Applies BYMINUTE rules specified in this Recur instance to the specified date list. If no BYMINUTE rules are * specified the date list is returned unmodified. * @param dates * @return */ private DateList getMinuteVariants(final DateList dates) { if (getMinuteList().isEmpty()) { return dates; } final DateList minutelyDates = getDateListInstance(dates); for (final Iterator i = dates.iterator(); i.hasNext();) { final Date date = (Date) i.next(); final Calendar cal = getCalendarInstance(date, true); for (final Iterator j = getMinuteList().iterator(); j.hasNext();) { final Integer minute = (Integer) j.next(); cal.set(Calendar.MINUTE, minute.intValue()); minutelyDates.add(Dates.getInstance(cal.getTime(), minutelyDates.getType())); } } return minutelyDates; }
/** * Applies BYMONTHDAY rules specified in this Recur instance to the specified date list. If no BYMONTHDAY rules are * specified the date list is returned unmodified. * @param dates * @return */ private DateList getMonthDayVariants(final DateList dates) { if (getMonthDayList().isEmpty()) { return dates; } final DateList monthDayDates = getDateListInstance(dates); for (final Iterator i = dates.iterator(); i.hasNext();) { final Date date = (Date) i.next(); final Calendar cal = getCalendarInstance(date, false); for (final Iterator j = getMonthDayList().iterator(); j.hasNext();) { final Integer monthDay = (Integer) j.next(); try { cal.set(Calendar.DAY_OF_MONTH, Dates.getAbsMonthDay(cal.getTime(), monthDay.intValue())); monthDayDates.add(Dates.getInstance(cal.getTime(), monthDayDates.getType())); } catch (IllegalArgumentException iae) { if (log.isTraceEnabled()) { log.trace("Invalid day of month: " + Dates.getAbsMonthDay(cal .getTime(), monthDay.intValue())); } } } } return monthDayDates; }
/** * Applies BYMONTH rules specified in this Recur instance to the specified date list. If no BYMONTH rules are * specified the date list is returned unmodified. * @param dates * @return */ private DateList getMonthVariants(final DateList dates) { if (getMonthList().isEmpty()) { return dates; } final DateList monthlyDates = getDateListInstance(dates); for (final Iterator i = dates.iterator(); i.hasNext();) { final Date date = (Date) i.next(); final Calendar cal = getCalendarInstance(date, true); for (final Iterator j = getMonthList().iterator(); j.hasNext();) { final Integer month = (Integer) j.next(); // Java months are zero-based.. // cal.set(Calendar.MONTH, month.intValue() - 1); cal.roll(Calendar.MONTH, (month.intValue() - 1) - cal.get(Calendar.MONTH)); monthlyDates.add(Dates.getInstance(cal.getTime(), monthlyDates.getType())); } } return monthlyDates; }
/** * Applies BYDAY rules specified in this Recur instance to the specified date list. If no BYDAY rules are specified * the date list is returned unmodified. * @param dates * @return */ private DateList getDayVariants(final DateList dates) { if (getDayList().isEmpty()) { return dates; } final DateList weekDayDates = getDateListInstance(dates); for (final Iterator i = dates.iterator(); i.hasNext();) { final Date date = (Date) i.next(); for (final Iterator j = getDayList().iterator(); j.hasNext();) { final WeekDay weekDay = (WeekDay) j.next(); // if BYYEARDAY or BYMONTHDAY is specified filter existing // list.. if (!getYearDayList().isEmpty() || !getMonthDayList().isEmpty()) { final Calendar cal = getCalendarInstance(date, true); if (weekDay.equals(WeekDay.getWeekDay(cal))) { weekDayDates.add(date); } } else { weekDayDates.addAll(getAbsWeekDays(date, dates.getType(), weekDay)); } } } return weekDayDates; }
for (final Iterator i = rdates.iterator(); i.hasNext();) { final RDate rdate = (RDate) i.next(); for (final Iterator j = rdate.getDates().iterator(); j.hasNext();) { try { final DateTime rdateOnset = applyOffsetFrom(calculateOnset((Date) j.next())); final DateList recurrenceDates = rrule.getRecur().getDates(initialOnsetUTC, onsetLimit, Value.DATE_TIME); for (final Iterator j = recurrenceDates.iterator(); j.hasNext();) { final DateTime rruleOnset = applyOffsetFrom((DateTime) j.next()); if (!rruleOnset.after(date) && rruleOnset.after(onset)) {
for (final Iterator i = candidates.iterator(); i.hasNext();) { candidate = (Date) i.next();
for (final Iterator i = candidates.iterator(); i.hasNext();) { candidate = (Date) i.next();
for (final Iterator j = rdate.getDates().iterator(); j.hasNext();) { final DateTime rdateTime = (DateTime) j.next(); if (period.includes(rdateTime)) { for (final Iterator j = rdate.getDates().iterator(); j.hasNext();) { final Date rdateDate = (Date) j.next(); if (period.includes(rdateDate)) { final DateList rruleDates = rrule.getRecur().getDates(start.getDate(), new Period(startMinusDuration, period.getEnd()), startValue); for (final Iterator j = rruleDates.iterator(); j.hasNext();) { final Date rruleDate = (Date) j.next(); recurrenceSet.add(new Period(new DateTime(rruleDate), rDuration));