I'm working with the implementation google-rfc-2445 (https://code.google.com/p/google-rfc-2445/) to generate the date which should be repeated following an event, not as a rule indicate (RRULE) that the repetition is done taking also note the time, ie the date is calculated next time I throw too.
example:
Start Date: 17/04/2013 8:30 a.m.
Rule: "RRULE: FREQ = DAILY; UNTIL = 20130430T083000Z, INTERVAL = 1"
Expected Result, Next Repetition: 4/18/2013 8:30 a.m.
Result Obtained, Next Repetition: 4/18/2013 00 00 00
This is the code I'm using
LocalDate start = new LocalDate(System.currentTimeMillis());
String ical = "RRULE:FREQ=DAILY;"
+ "UNTIL=20130430T083000Z;"
+ "INTERVAL=1;";
//Next Notification
Date f = null;
for (LocalDate date
: LocalDateIteratorFactory.createLocalDateIterable(ical, start, false)) {
f = date.toDateTimeAtCurrentTime().toLocalDate().toDate();
break;
}
System.out.println("Next = " + f);
The printing result is Next = Wed Apr 17 00:00:00 COT 2013
It is the existence of "BYHOUR = 8; BYMINUTE = 05; BYSECOND = 10" but not how to use it, if I can lend a hand, thank you.
LocalDateIteratorFactory
produces dates without a corresponding time, but it sounds like you want DateTimes. Use DateTimeIteratorFactory
instead.
Also,
LocalDate start = new LocalDate(System.currentTimeMillis());
is probably not equivalent to
Start Date: 17/04/2013 8:30 a.m.
You probably want to use DateTime
DateTime start = new DateTime(2013, 4, 17, 8, 30, 0);
Finally, there's no reason to use the Joda time compatibility layer if what you want at the end is
Date f = null;
Just use the java.util
compatibility layer instead.
I would suggest sticking to Joda time though, since java.util
dates are a mess.