当前位置:   article > 正文

java 解析 ical,如何用Java解析iCal RRULE

java 解析 ical,如何用Java解析iCal RRULE

I have the following iCal recurrence rule examples:

"RRULE:FREQ=YEARLY;INTERVAL=2"

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

I need a Java library to parse the RRULE patterns to handle in an object. Are there any good Java libraries?

ical library does not build correctly;

google ical implementation is not supported for ages;

maven repository can propose a lot of implementations, but I did not got any actual one.

解决方案

You can use lib-recur

It is still supported and handle RFC 5545 and 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

}

You can install it with maven

org.dmfs

lib-recur

0.10.2

Or with gradle

// https://mvnrepository.com/artifact/org.dmfs/lib-recur

compile group: 'org.dmfs', name: 'lib-recur', version: '0.10.2'

More documentation is available here : https://github.com/dmfs/lib-recur

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/258437
推荐阅读
相关标签
  

闽ICP备14008679号