赞
踩
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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。