public boolean checkMoment(Date date) { if (calendar != null) { Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0)); Predicate<CalendarComponent> periodRule = new PeriodRule<>(period); Filter<CalendarComponent> filter = new Filter<>(new Predicate[] {periodRule}, Filter.MATCH_ANY); Collection<CalendarComponent> events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT)); if (events != null && !events.isEmpty()) { return true; } } return false; }
private static long durationToMs(Dur d) { long ms = 0; ms += d.getSeconds() * DateUtils.SECOND_IN_MILLIS; ms += d.getMinutes() * DateUtils.MINUTE_IN_MILLIS; ms += d.getHours() * DateUtils.HOUR_IN_MILLIS; ms += d.getDays() * DateUtils.DAY_IN_MILLIS; ms += d.getWeeks() * DateUtils.WEEK_IN_MILLIS; return ms; }
/** * {@inheritDoc} */ public final int compareTo(final Object arg0) { return compareTo((Dur) arg0); }
dur = new Dur(start, evend); if (dur.getWeeks() != 0) { dur = new Dur(dur.getWeeks() + 1); } else { dur = new Dur(dur.getDays() + 1, dur.getHours(), dur.getMinutes(), dur.getSeconds()); for (int j = 0; j < startDates.size(); j++) { Date startDate = (Date)startDates.get(j); Date endDate = new Date(dur.getTime(startDate)); until = new DateTime(dur.getTime(until)); ((DateTime)until).setUtc(true); } else { until = new Date(dur.getTime(until));
if ((!isNegative() && duration.isNegative()) || (isNegative() && !duration.isNegative())) { sum = new Dur(weeks + duration.weeks); + duration.days : duration.days; sum = new Dur(daySum, hourSum, minuteSum, secondSum);
private DateTime inc(final DateTime dt, final Dur dur) { final java.util.Date jdt = dur.getTime(dt); return new DateTime(jdt); }
endType = StartEndComponent.endTypeDate; } else if (scheduleReply || todo || vpoll) { Dur years = new Dur(520); // about 10 years Date now = new Date(new java.util.Date().getTime()); dtEnd = new DtEnd(new Date(years.getTime(now))); dtEnd.getParameters().add(Value.DATE); dur = new Dur(1, 0, 0, 0); // 1 day } else { dur = new Dur(0, 0, 0, 0); // No duration ev.getDtend()).toString(); if (!durVal.equals(ev.getDuration())) { chg.changed(PropertyInfoIndex.DURATION, ev.getDuration(), durVal);
/** * {@inheritDoc} */ public final String getValue() { // return DurationFormat.getInstance().format(getDuration()); return duration.toString(); }
/** * Returns a date representing the end of this duration from the specified start date. * @param start the date to start the duration * @return the end of the duration as a date */ public final Date getTime(final Date start) { final Calendar cal = Calendar.getInstance(); cal.setTime(start); if (isNegative()) { cal.add(Calendar.WEEK_OF_YEAR, -weeks); cal.add(Calendar.DAY_OF_WEEK, -days); cal.add(Calendar.HOUR_OF_DAY, -hours); cal.add(Calendar.MINUTE, -minutes); cal.add(Calendar.SECOND, -seconds); } else { cal.add(Calendar.WEEK_OF_YEAR, weeks); cal.add(Calendar.DAY_OF_WEEK, days); cal.add(Calendar.HOUR_OF_DAY, hours); cal.add(Calendar.MINUTE, minutes); cal.add(Calendar.SECOND, seconds); } return cal.getTime(); }
if ((!isNegative() && duration.isNegative()) || (isNegative() && !duration.isNegative())) { sum = new Dur(weeks + duration.weeks); + duration.days : duration.days; sum = new Dur(daySum, hourSum, minuteSum, secondSum);
/** * Constructs a new period with the specified start date and duration. * * @param start * the start date of the period * @param duration * the duration of the period */ public Period(final DateTime start, final Dur duration) { super(start, new DateTime(duration.getTime(start))); this.duration = duration; normalise(); }
/** * {@inheritDoc} */ public final String getValue() { // return DurationFormat.getInstance().format(getDuration()); return duration.toString(); }
/** * Returns a date representing the end of this duration from the specified start date. * @param start the date to start the duration * @return the end of the duration as a date */ public final Date getTime(final Date start) { final Calendar cal; if (start instanceof net.fortuna.ical4j.model.Date) { cal = Dates.getCalendarInstance((net.fortuna.ical4j.model.Date)start); } else { cal = Calendar.getInstance(); } cal.setTime(start); if (isNegative()) { cal.add(Calendar.WEEK_OF_YEAR, -weeks); cal.add(Calendar.DAY_OF_WEEK, -days); cal.add(Calendar.HOUR_OF_DAY, -hours); cal.add(Calendar.MINUTE, -minutes); cal.add(Calendar.SECOND, -seconds); } else { cal.add(Calendar.WEEK_OF_YEAR, weeks); cal.add(Calendar.DAY_OF_WEEK, days); cal.add(Calendar.HOUR_OF_DAY, hours); cal.add(Calendar.MINUTE, minutes); cal.add(Calendar.SECOND, seconds); } return cal.getTime(); }
if (isNegative() != arg0.isNegative()) { if (isNegative()) { return Integer.MIN_VALUE; else if (getWeeks() != arg0.getWeeks()) { result = getWeeks() - arg0.getWeeks(); else if (getDays() != arg0.getDays()) { result = getDays() - arg0.getDays(); else if (getHours() != arg0.getHours()) { result = getHours() - arg0.getHours(); else if (getMinutes() != arg0.getMinutes()) { result = getMinutes() - arg0.getMinutes(); result = getSeconds() - arg0.getSeconds(); if (isNegative()) { return -result;
/** * Provides a negation of this instance. * @return a Dur instance that represents a negation of this instance */ public final Dur negate() { final Dur negated = new Dur(days, hours, minutes, seconds); negated.weeks = weeks; negated.negative = !negative; return negated; }
if ((!isNegative() && duration.isNegative()) || (isNegative() && !duration.isNegative())) { sum = new Dur(weeks + duration.weeks); + duration.days : duration.days; sum = new Dur(daySum, hourSum, minuteSum, secondSum);
/** * Constructs a new period with the specified start date and duration. * * @param start * the start date of the period * @param duration * the duration of the period */ public Period(final DateTime start, final Dur duration) { super(start, new DateTime(duration.getTime(start))); this.duration = duration; normalise(); }