/** * {@inheritDoc} */ public final void setTimeZone(TimeZone timezone) { if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) { periods.setTimeZone(timezone); } else { super.setTimeZone(timezone); } }
/** * */ public void testIsEmpty() { assertTrue(periodList.isEmpty()); }
/** * {@inheritDoc} */ public final void setTimeZone(TimeZone timezone) { if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) { periods.setTimeZone(timezone); } else { super.setTimeZone(timezone); } }
/** * {@inheritDoc} */ public final void setTimeZone(TimeZone timezone) { if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) { periods.setTimeZone(timezone); } else { super.setTimeZone(timezone); } }
/** * {@inheritDoc} */ public final void setTimeZone(TimeZone timezone) { if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) { periods.setTimeZone(timezone); } else { super.setTimeZone(timezone); } }
/** * {@inheritDoc} */ public final String getValue() { if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) { return Strings.valueOf(getPeriods()); } return super.getValue(); }
/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Iterator i = subtractions.iterator(); i.hasNext();) { final Period subtraction = (Period) i.next(); for (final Iterator j = result.iterator(); j.hasNext();) { final Period period = (Period) j.next(); tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
/** * {@inheritDoc} */ public final String getValue() { if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) { return Strings.valueOf(getPeriods()); } return super.getValue(); }
/** * {@inheritDoc} */ public final String getValue() { if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) { return Strings.valueOf(getPeriods()); } return super.getValue(); }
/** * {@inheritDoc} */ public final String getValue() { if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) { return Strings.valueOf(getPeriods()); } return super.getValue(); }
/** * */ public void testCalculateRecurrenceSetNotEmpty() { PeriodList recurrenceSet = event.calculateRecurrenceSet(period); assertTrue(!recurrenceSet.isEmpty()); }
/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Period subtraction : subtractions) { for (final Period period : result) { tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Period subtraction : subtractions) { for (final Period period : result) { tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Period subtraction : subtractions) { for (final Period period : result) { tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
/** * Subtracts the intersection of this list with the specified list of * periods from this list and returns the results as a new period list. If * no intersection is identified this list is returned. * * @param subtractions * a list of periods to subtract from this list * @return a period list */ public final PeriodList subtract(final PeriodList subtractions) { if (subtractions == null || subtractions.isEmpty()) { return this; } PeriodList result = this; PeriodList tmpResult = new PeriodList(); for (final Period subtraction : subtractions) { for (final Period period : result) { tmpResult.addAll(period.subtract(subtraction)); } result = tmpResult; tmpResult = new PeriodList(); } return result; }
/** * Test to ensure that EXDATE properties are correctly applied. * * @throws ParseException */ public void testGetConsumedTimeWithExDate2() throws IOException, ParserException { InputStream in = getClass().getResourceAsStream("/samples/valid/friday13.ics"); net.fortuna.ical4j.model.Calendar calendar = new CalendarBuilder().build(in); VEvent event = (VEvent) calendar.getComponent(Component.VEVENT); Calendar cal = Calendar.getInstance(); cal.set(1997, 8, 2); Date start = new Date(cal.getTime()); cal.set(1997, 8, 4); Date end = new Date(cal.getTime()); PeriodList periods = event.getConsumedTime(start, end); assertTrue(periods.isEmpty()); }
public final void testGetConsumedTime3() throws Exception { String resource = "/samples/valid/calconnect10.ics"; net.fortuna.ical4j.model.Calendar calendar = loadCalendar(resource); VEvent vev = (VEvent) calendar.getComponent(Component.VEVENT); Date start = vev.getStartDate().getDate(); Calendar cal = getCalendarInstance(); cal.add(Calendar.YEAR, 1); Date latest = new Date(cal.getTime()); PeriodList pl = vev.getConsumedTime(start, latest); assertTrue(!pl.isEmpty()); }
if (!periods.isEmpty() && normalise) { periods = periods.normalise();
/** * Unit tests for {@link PeriodList#normalise()}. */ public void testNormalise() { // test a list of periods consuming no time.. PeriodList periods = new PeriodList(); DateTime start = new DateTime(); periods.add(new Period(start, start)); DateTime start2 = new DateTime(); periods.add(new Period(start2, start2)); assertTrue(periods.normalise().isEmpty()); } }
/** * Test to ensure that EXDATE properties are correctly applied. * * @throws ParseException */ public void testGetConsumedTimeWithExDate() throws ParseException { VEvent event1 = new VEvent(new DateTime("20050103T080000"), java.time.Duration.ofMinutes(15), "Event 1"); Recur rRuleRecur = new Recur("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR"); RRule rRule = new RRule(rRuleRecur); event1.getProperties().add(rRule); ParameterList parameterList = new ParameterList(); parameterList.add(Value.DATE); ExDate exDate = new ExDate(parameterList, "20050106"); event1.getProperties().add(exDate); Date start = new Date("20050106"); Date end = new Date("20050107"); PeriodList list = event1.getConsumedTime(start, end); assertTrue(list.isEmpty()); }