net.fortuna.ical4j.model.property.Duration.getDuration()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中net.fortuna.ical4j.model.property.Duration.getDuration()方法的一些代码示例,展示了Duration.getDuration()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.getDuration()方法的具体详情如下:
包路径:net.fortuna.ical4j.model.property.Duration
类名称:Duration
方法名:getDuration

Duration.getDuration介绍

暂无

代码示例

代码示例来源:origin: org.bedework.caleng/bw-calendar-engine-facade

/** Return a value based on this value plus a duration.
 *
 * @param val
 * @return BwDateTime
 * @throws CalFacadeException
 */
public BwDateTime addDuration(final BwDuration val) throws CalFacadeException {
 return addDuration(val.makeDuration().getDuration());
}

代码示例来源:origin: 1and1/cosmo

public Dur getDisplayAlarmDuration() {
  VAlarm alarm = getDisplayAlarm();
  if(alarm==null) {
    return null;
  }
  
  Duration dur =  (Duration) alarm.getProperties().getProperty(Property.DURATION);
  if(dur!=null) {
    return dur.getDuration();
  }
  else {
    return null;
  }
}

代码示例来源:origin: net.oneandone.cosmo/cosmo-core

public Dur getDisplayAlarmDuration() {
  VAlarm alarm = getDisplayAlarm();
  if(alarm==null) {
    return null;
  }
  
  Duration dur =  (Duration) alarm.getProperties().getProperty(Property.DURATION);
  if(dur!=null) {
    return dur.getDuration();
  }
  else {
    return null;
  }
}

代码示例来源:origin: net.oneandone.cosmo/cosmo-core

nextTriggerDate = Dates.getInstance(dur.getDuration().getTime(nextTriggerDate), nextTriggerDate);
dates.add(nextTriggerDate);

代码示例来源:origin: net.oneandone.cosmo/cosmo-core

/**
 * Get the duration for an event.  If the DURATION property
 * exist, use that.  Else, calculate duration from DTSTART and
 * DTEND.
 * @param event The event.
 * @return duration for event
 */
public static Dur getDuration(VEvent event) {
  Duration duration = (Duration)
    event.getProperties().getProperty(Property.DURATION);
  if (duration != null) {
    return duration.getDuration();
  }
  DtStart dtstart = event.getStartDate();
  if (dtstart == null) {
    return null;
  }
  DtEnd dtend = (DtEnd) event.getProperties().getProperty(Property.DTEND);
  if (dtend == null) {
    return null;
  }
  return new Duration(dtstart.getDate(), dtend.getDate()).getDuration();
}

代码示例来源:origin: 1and1/cosmo

/**
 * Get the duration for an event.  If the DURATION property
 * exist, use that.  Else, calculate duration from DTSTART and
 * DTEND.
 * @param event The event.
 * @return duration for event
 */
public static Dur getDuration(VEvent event) {
  Duration duration = (Duration)
    event.getProperties().getProperty(Property.DURATION);
  if (duration != null) {
    return duration.getDuration();
  }
  DtStart dtstart = event.getStartDate();
  if (dtstart == null) {
    return null;
  }
  DtEnd dtend = (DtEnd) event.getProperties().getProperty(Property.DTEND);
  if (dtend == null) {
    return null;
  }
  return new Duration(dtstart.getDate(), dtend.getDate()).getDuration();
}

代码示例来源:origin: org.bedework/bw-ical4j-cl

if (freeDuration.getDuration().compareTo(duration) >= 0) {
  fb.getPeriods().add(new Period(lastPeriodEnd, freeDuration.getDuration()));

代码示例来源:origin: apache/ofbiz-framework

protected static Double fromDuration(PropertyList propertyList) {
  Duration iCalObj = (Duration) propertyList.getProperty(Duration.DURATION);
  if (iCalObj == null) {
    return null;
  }
  Dur dur = iCalObj.getDuration();
  TimeDuration td = new TimeDuration(0, 0, (dur.getWeeks() * 7) + dur.getDays(), dur.getHours(), dur.getMinutes(), dur.getSeconds(), 0);
  return (double) TimeDuration.toLong(td);
}

代码示例来源:origin: net.oneandone.cosmo/cosmo-core

/**
   * 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;
  }
}

代码示例来源:origin: net.oneandone.cosmo/cosmo-core

/**
 * 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;
}

代码示例来源:origin: 1and1/cosmo

/**
   * 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;
  }
}

代码示例来源:origin: 1and1/cosmo

/**
 * 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;
}

代码示例来源:origin: org.bedework/bw-ical4j-cl

/**
 * 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;
}

代码示例来源:origin: net.oneandone.ical4j/ical4j

public FreeBusy build() {
    final FreeBusy fb = new FreeBusy();
    fb.getParameters().add(FbType.FREE);
    final PeriodList periods = getConsumedTime(components, start, end);
    final DateRange range = new DateRange(start, end);
    // Add final consumed time to avoid special-case end-of-list processing
    periods.add(new Period(end, end));
    DateTime lastPeriodEnd = new DateTime(start);
    // where no time is consumed set the last period end as the range start..
    for (final Period period : periods) {
      // check if period outside bounds.. or period intersects with the end of the range..
      if (range.contains(period) || 
          (range.intersects(period) && period.getStart().after(range.getRangeStart()))) {
        
        // calculate duration between this period start and last period end..
        final Duration freeDuration = new Duration(lastPeriodEnd, period.getStart());
        if (freeDuration.getDuration().compareTo(duration) >= 0) {
          fb.getPeriods().add(new Period(lastPeriodEnd, freeDuration.getDuration()));
        }
      }
      
      if (period.getEnd().after(lastPeriodEnd)) {
        lastPeriodEnd = period.getEnd();
      }
    }
    return fb;
  }
}

代码示例来源:origin: org.bedework.ical4j/ical4j

public FreeBusy build() {
    final FreeBusy fb = new FreeBusy();
    fb.getParameters().add(FbType.FREE);
    final PeriodList periods = getConsumedTime(components, start, end);
    final DateRange range = new DateRange(start, end);
    // Add final consumed time to avoid special-case end-of-list processing
    periods.add(new Period(end, end));
    DateTime lastPeriodEnd = new DateTime(start);
    // where no time is consumed set the last period end as the range start..
    for (final Period period : periods) {
      // check if period outside bounds.. or period intersects with the end of the range..
      if (range.contains(period) || 
          (range.intersects(period) && period.getStart().after(range.getRangeStart()))) {
        
        // calculate duration between this period start and last period end..
        final Duration freeDuration = new Duration(lastPeriodEnd, period.getStart());
        if (freeDuration.getDuration().compareTo(duration) >= 0) {
          fb.getPeriods().add(new Period(lastPeriodEnd, freeDuration.getDuration()));
        }
      }
      
      if (period.getEnd().after(lastPeriodEnd)) {
        lastPeriodEnd = period.getEnd();
      }
    }
    return fb;
  }
}

代码示例来源:origin: ical4j/ical4j

public FreeBusy build() {
    final FreeBusy fb = new FreeBusy();
    fb.getParameters().add(FbType.FREE);
    final PeriodList periods = getConsumedTime(components, start, end);
    final DateRange range = new DateRange(start, end);
    // Add final consumed time to avoid special-case end-of-list processing
    periods.add(new Period(end, end));
    DateTime lastPeriodEnd = new DateTime(start);
    // where no time is consumed set the last period end as the range start..
    for (final Period period : periods) {
      // check if period outside bounds.. or period intersects with the end of the range..
      if (range.contains(period) || 
          (range.intersects(period) && period.getStart().after(range.getRangeStart()))) {
        
        // calculate duration between this period start and last period end..
        final Duration freeDuration = new Duration(lastPeriodEnd, period.getStart());
        if (new TemporalAmountComparator().compare(freeDuration.getDuration(), duration) >= 0) {
          fb.getPeriods().add(new Period(lastPeriodEnd, freeDuration.getDuration()));
        }
      }
      
      if (period.getEnd().after(lastPeriodEnd)) {
        lastPeriodEnd = period.getEnd();
      }
    }
    return fb;
  }
}

代码示例来源:origin: org.mnode.ical4j/ical4j

public FreeBusy build() {
    final FreeBusy fb = new FreeBusy();
    fb.getParameters().add(FbType.FREE);
    final PeriodList periods = getConsumedTime(components, start, end);
    final DateRange range = new DateRange(start, end);
    // Add final consumed time to avoid special-case end-of-list processing
    periods.add(new Period(end, end));
    DateTime lastPeriodEnd = new DateTime(start);
    // where no time is consumed set the last period end as the range start..
    for (final Period period : periods) {
      // check if period outside bounds.. or period intersects with the end of the range..
      if (range.contains(period) || 
          (range.intersects(period) && period.getStart().after(range.getRangeStart()))) {
        
        // calculate duration between this period start and last period end..
        final Duration freeDuration = new Duration(lastPeriodEnd, period.getStart());
        if (new TemporalAmountComparator().compare(freeDuration.getDuration(), duration) >= 0) {
          fb.getPeriods().add(new Period(lastPeriodEnd, freeDuration.getDuration()));
        }
      }
      
      if (period.getEnd().after(lastPeriodEnd)) {
        lastPeriodEnd = period.getEnd();
      }
    }
    return fb;
  }
}

代码示例来源:origin: ical4j/ical4j

dtEnd = new DtEnd(Dates.getInstance(Date.from(dtStart.getDate().toInstant().plus(vEventDuration.getDuration())),
    dtStart.getParameter(Parameter.VALUE)));
if (dtStart.isUtc()) {

代码示例来源:origin: net.oneandone.ical4j/ical4j

dtEnd = new DtEnd(Dates.getInstance(vEventDuration.getDuration()
    .getTime(dtStart.getDate()), (Value) dtStart
    .getParameter(Parameter.VALUE)));

代码示例来源:origin: org.bedework.ical4j/ical4j

dtEnd = new DtEnd(Dates.getInstance(vEventDuration.getDuration()
    .getTime(dtStart.getDate()), (Value) dtStart
    .getParameter(Parameter.VALUE)));

相关文章

微信公众号

最新文章

更多