我检查 ical4j 库。我需要计算事件发生时间。有用的计算示例是here。我尝试转移start date
和end date
。原始start date
是20101113
- 2010年11月,星期六(它在模式上映射,请参见BYDAY=...SA
)。我想要不关心是否开始匹配。所以我使用值为start date
的{{1}} - 2010年11月,星期五(它没有按照模式中的任何一天进行映射,请参阅20101112
)
BYDAY=MO,TU,SA
结果是
[20101112T000000Z / 20101113T000000Z,20101113T000000Z / P1D,20101129T000000Z / P1D,20101130T000000Z / P1D,20101204T000000Z / P1D,20101220T000000Z / P1D,20101221T000000Z / P1D,20101225T000000Z / P1D]
几乎与预期一致(结果 VEvent event = new ContentBuilder().vevent {
dtstart('20101112', parameters: parameters() {value('DATE')})
dtend('20101113', parameters: parameters() {value('DATE')})
rrule('FREQ=WEEKLY;WKST=MO;INTERVAL=3;BYDAY=MO,TU,SA')
}
def dates = event.calculateRecurrenceSet(new Period('20101101T000000/20110101T000000'))
println dates
中的第一个句点除外)。所以我继续研究如何排除一个。在调试模式下,我看到
20101112T000000Z/20101113T000000Z
尤里卡!我找到了标记来检测生成集中的冗余日期(损坏的时间段为空持续时间)。我继续使用null值处理它的过滤周期。但过滤器没有过滤任何东西继续检查...
result = {PeriodList@1497} size = 8
0 = {Period@2240} "20101112T000000Z/20101113T000000Z"
duration = null
rangeStart = {DateTime@2243} "20101112T000000Z"
rangeEnd = {DateTime@2244} "20101113T000000Z"
1 = {Period@2264} "20101113T000000Z/P1D"
duration = {Dur@2284} "P1D"
rangeStart = {DateTime@2285} "20101113T000000Z"
rangeEnd = {DateTime@2286} "20101114T000000Z"
2 = {Period@2265} "20101129T000000Z/P1D"
duration = {Dur@2284} "P1D"
rangeStart = {DateTime@2290} "20101129T000000Z"
rangeEnd = {DateTime@2291} "20101130T000000Z"
3 = {Period@2266} "20101130T000000Z/P1D"
duration = {Dur@2284} "P1D"
rangeStart = {DateTime@2295} "20101130T000000Z"
rangeEnd = {DateTime@2296} "20101201T000000Z"
4 = {Period@2267} "20101204T000000Z/P1D"
duration = {Dur@2284} "P1D"
rangeStart = {DateTime@2300} "20101204T000000Z"
rangeEnd = {DateTime@2301} "20101205T000000Z"
5 = {Period@2268} "20101220T000000Z/P1D"
duration = {Dur@2284} "P1D"
rangeStart = {DateTime@2315} "20101220T000000Z"
rangeEnd = {DateTime@2316} "20101221T000000Z"
6 = {Period@2269} "20101221T000000Z/P1D"
duration = {Dur@2284} "P1D"
rangeStart = {DateTime@2310} "20101221T000000Z"
rangeEnd = {DateTime@2311} "20101222T000000Z"
7 = {Period@2270} "20101225T000000Z/P1D"
duration = {Dur@2284} "P1D"
rangeStart = {DateTime@2305} "20101225T000000Z"
rangeEnd = {DateTime@2306} "20101226T000000Z"
如您所见,课程package net.fortuna.ical4j.model;
...
public class Period extends DateRange implements Comparable<Period> {
private static final long serialVersionUID = 7321090422911676490L;
private Dur duration;
...
public final Dur getDuration() {
if (duration == null) {
return new Dur(getStart(), getEnd());
}
return duration;
}
...
有Period
和private Dur duration
。没有解决方法,我无法访问public final Dur getDuration()
我该怎么办?
duration
类并重建库 - 遵循不良支持新库版本。Period
开发人员展开ical4j
外观 - 需要时间进行更改和发布。Period
(这是不可靠的解决方案)。