private DateTime inc(final DateTime dt, final Dur dur) { final java.util.Date jdt = dur.getTime(dt); return new DateTime(jdt); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * */ public void testGetTime() { assertEquals(expectedTime, duration.getTime(startTime)); }
private static DateTime parseEndDate(String value, boolean resolve) throws ParseException { DateTime end = null; try { end = new DateTime(value.substring(value.indexOf('/') + 1)); } catch (ParseException e) { if (resolve) { final Dur duration = parseDuration(value); end = new DateTime(duration.getTime(parseStartDate(value))); } else { throw e; } } return end; }
private static DateTime parseEndDate(String value, boolean resolve) throws ParseException { DateTime end; try { end = new DateTime(value.substring(value.indexOf('/') + 1)); } catch (ParseException e) { if (resolve) { final Dur duration = parseDuration(value); end = new DateTime(duration.getTime(parseStartDate(value))); } else { throw e; } } return end; }
private static DateTime parseEndDate(String value, boolean resolve) throws ParseException { DateTime end; try { end = new DateTime(value.substring(value.indexOf('/') + 1)); } catch (ParseException e) { if (resolve) { final Dur duration = parseDuration(value); end = new DateTime(duration.getTime(parseStartDate(value))); } else { throw e; } } return end; }
/** * Get the last occurring modification or occurrence, whichever occurred * last. * @param note NoteItem * @param context TriageStatusQueryContext * @return NoteItem */ private NoteItem getDoneFromRecurringNote(NoteItem note, TriageStatusQueryContext context) { EventStamp eventStamp = StampUtils.getEventStamp(note); Date currentDate = context.getPointInTime(); Date pastDate = getDurToUseForExpanding(eventStamp, false).getTime( currentDate); // calculate the previous occurrence or modification NoteItem latest = getLatestInstanceOrModification(eventStamp, pastDate, currentDate, context.getTimeZone()); return latest; }
/** * Get the next occurrence or modification for a recurring event, whichever * occurrs sooner relative to a point in time. * @param note NoteItem * @param context TriageStatusQueryContext * @return Set<NoteItem> */ private NoteItem getLaterFromRecurringNote(NoteItem note, TriageStatusQueryContext context) { EventStamp eventStamp = StampUtils.getEventStamp(note); Date currentDate = context.getPointInTime(); Date futureDate = getDurToUseForExpanding(eventStamp, true).getTime( currentDate); // calculate the next occurrence or LATER modification NoteItem first = getFirstInstanceOrModification(eventStamp, currentDate, futureDate, context.getTimeZone()); return first; }
/** * Get the last occurring modification or occurrence, whichever occurred * last. * @param note NoteItem * @param context TriageStatusQueryContext * @return NoteItem */ private NoteItem getDoneFromRecurringNote(NoteItem note, TriageStatusQueryContext context) { EventStamp eventStamp = StampUtils.getEventStamp(note); Date currentDate = context.getPointInTime(); Date pastDate = getDurToUseForExpanding(eventStamp, false).getTime( currentDate); // calculate the previous occurrence or modification NoteItem latest = getLatestInstanceOrModification(eventStamp, pastDate, currentDate, context.getTimeZone()); return latest; }
/** * Get the next occurrence or modification for a recurring event, whichever * occurrs sooner relative to a point in time. * @param note NoteItem * @param context TriageStatusQueryContext * @return Set<NoteItem> */ private NoteItem getLaterFromRecurringNote(NoteItem note, TriageStatusQueryContext context) { EventStamp eventStamp = StampUtils.getEventStamp(note); Date currentDate = context.getPointInTime(); Date futureDate = getDurToUseForExpanding(eventStamp, true).getTime( currentDate); // calculate the next occurrence or LATER modification NoteItem first = getFirstInstanceOrModification(eventStamp, currentDate, futureDate, context.getTimeZone()); return first; }
public Date getEndDate() { VEvent event = getEvent(); if(event==null) { return null; } DtEnd dtEnd = event.getEndDate(false); // if no DTEND, then calculate endDate from DURATION if (dtEnd == null) { Date startDate = getStartDate(); Dur duration = getDuration(); // if no DURATION, then there is no end time if(duration==null) { return null; } Date endDate = null; if(startDate instanceof DateTime) { endDate = new DateTime(startDate); } else { endDate = new Date(startDate); } endDate.setTime(duration.getTime(startDate).getTime()); return endDate; } return dtEnd.getDate(); }
Date end = new DateTime(days100.getTime(start)); DateList dl = r.getDates(seed, start, end, Value.DATE_TIME);
/** * Gets end date. * @param comp The component. * @return The date. */ private Date getEndDate(Component comp) { DtEnd dtEnd = (DtEnd) comp.getProperties().getProperty(Property.DTEND); // No DTEND? No problem, we'll use the DURATION if present. if (dtEnd == null) { Date dtStart = getStartDate(comp); Duration duration = (Duration) comp.getProperties().getProperty( Property.DURATION); if (duration != null) { dtEnd = new DtEnd(org.unitedinternet.cosmo.calendar.util.Dates.getInstance(duration.getDuration() .getTime(dtStart), dtStart)); } } return (dtEnd != null) ? dtEnd.getDate() : null; } }
/** * Gets end date. * * @param comp The component. * @return The date. */ private Date getEndDate(Component comp) { DtEnd dtEnd = (DtEnd) comp.getProperties().getProperty(Property.DTEND); // No DTEND? No problem, we'll use the DURATION if present. if (dtEnd == null) { Date dtStart = getStartDate(comp); Duration duration = (Duration) comp.getProperties().getProperty( Property.DURATION); if (duration != null) { dtEnd = new DtEnd(org.unitedinternet.cosmo.calendar.util.Dates.getInstance(duration.getDuration() .getTime(dtStart), dtStart)); } } return (dtEnd != null) ? dtEnd.getDate() : null; }
/** * Gets end date. * * @param comp The component. * @return The date. */ private Date getEndDate(Component comp) { DtEnd dtEnd = (DtEnd) comp.getProperties().getProperty(Property.DTEND); // No DTEND? No problem, we'll use the DURATION if present. if (dtEnd == null) { Date dtStart = getStartDate(comp); Duration duration = (Duration) comp.getProperties().getProperty( Property.DURATION); if (duration != null) { dtEnd = new DtEnd(org.unitedinternet.cosmo.calendar.util.Dates.getInstance(duration.getDuration() .getTime(dtStart), dtStart)); } } return (dtEnd != null) ? dtEnd.getDate() : null; }
/** * Gets end date. * @param comp The component. * @return The date. */ private Date getEndDate(Component comp) { DtEnd dtEnd = (DtEnd) comp.getProperties().getProperty(Property.DTEND); // No DTEND? No problem, we'll use the DURATION if present. if (dtEnd == null) { Date dtStart = getStartDate(comp); Duration duration = (Duration) comp.getProperties().getProperty( Property.DURATION); if (duration != null) { dtEnd = new DtEnd(org.unitedinternet.cosmo.calendar.util.Dates.getInstance(duration.getDuration() .getTime(dtStart), dtStart)); } } return (dtEnd != null) ? dtEnd.getDate() : null; } }
/** * Convenience method to pull the DTEND out of the property list. If DTEND was not specified, use the DTSTART + * DURATION to calculate it. * @param deriveFromDuration specifies whether to derive an end date from the event duration where an end date is * not found * @return The end for this VEVENT. */ public final DtEnd getEndDate(final boolean deriveFromDuration) { DtEnd dtEnd = (DtEnd) getProperty(Property.DTEND); // No DTEND? No problem, we'll use the DURATION. if (dtEnd == null && deriveFromDuration && getDuration() != null) { final DtStart dtStart = getStartDate(); final Duration vEventDuration = getDuration(); dtEnd = new DtEnd(Dates.getInstance(vEventDuration.getDuration() .getTime(dtStart.getDate()), (Value) dtStart .getParameter(Parameter.VALUE))); if (dtStart.isUtc()) { dtEnd.setUtc(true); } } return dtEnd; }
private BwDateTime addDuration(final Dur val) throws CalFacadeException { DtEnd dtEnd; java.util.Date endDt = val.getTime(makeDate()); DtStart dtStart = makeDtStart(Timezones.getTzRegistry()); if (getDateType()) { dtEnd = new DtEnd(new Date(endDt)); addIcalParameter(dtEnd, Value.DATE); } else { DateTime d = new DateTime(endDt); Parameter tzid = getIcalParameter(dtStart, "TZID"); if (tzid != null) { DateTime sd = (DateTime)dtStart.getDate(); d.setTimeZone(sd.getTimeZone()); } // dtEnd = new DtEnd(d, dtStart.isUtc()); dtEnd = new DtEnd(d); if (tzid != null) { addIcalParameter(dtEnd, tzid); } else if (dtStart.isUtc()) { dtEnd.setUtc(true); } } return makeBwDateTime(dtEnd); }