java - 如何在 Java 中解析 iCal RRULE

标签 java icalendar rrule

<分区>

我有以下 iCal recurrence rule示例:

"RRULE:FREQ=YEARLY;INTERVAL=2"
"RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,WE,TH"

我需要一个 Java 库来解析 RRULE 模式以在对象中处理。有什么好的 Java 库吗?


最佳答案

您可以使用 lib-recur

它仍然受支持并处理 RFC 5545 和 RFC 2445。

RecurrenceRule rule = new RecurrenceRule("FREQ=YEARLY;BYMONTHDAY=23;BYMONTH=5");

DateTime start = new DateTime(1982, 4 /* 0-based month numbers! */,23);

RecurrenceRuleIterator it = rule.iterator(start);

int maxInstances = 100; // limit instances for rules that recur forever

while (it.hasNext() && (!rule.isInfinite() || maxInstances-- > 0))
{
    DateTime nextInstance = it.nextDateTime();
    // do something with nextInstance
}

可以用maven安装

<!-- https://mvnrepository.com/artifact/org.dmfs/lib-recur -->
<dependency>
    <groupId>org.dmfs</groupId>
    <artifactId>lib-recur</artifactId>
     <version>0.10.2</version>
</dependency>

或者用gradle

// https://mvnrepository.com/artifact/org.dmfs/lib-recur 
compile group: 'org.dmfs', name: 'lib-recur', version: '0.10.2'

此处提供更多文档:https://github.com/dmfs/lib-recur

关于java - 如何在 Java 中解析 iCal RRULE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43319008/

相关文章:

java - Maven 构建失败,涉及依赖项 JAR 中的 MANIFEST.MF 类路径

java - JBOSS:无效算法http://www.w3.org/TR/2001/REC-xml-c14n-20010315(InclusiveC14N)

google-calendar-api - 有没有办法以编程方式将ICS导入Google日历?

python - 如何从 Python 中的 RRULE 中查找频率?

java - 连续多次调用同一方法,且方法名不重复

outlook - 无需 MS 软件即可接受 Outlook 邀请(.ics 附件)

calendar - 来自 iCal Feed URL 的事件在 Google 日历中显示为 "Busy"

python - 使用python获取两个日期之间的周数

java - 如何使用 weblogic 10.x 托管服务器运行 Jprofile?