I am using Time4j to parse recurring intervals like this:
IsoRecurrence.parseTimestampIntervals("R/2019-01-01T00:00:00/P1D")
This will give me an iterator with infinite number of daily recurring instances starting from the beginning of 2019.
Is it possible to only iterate the instances between a start date and end date, let's say e.g. for June, without changing the original rule?
Basically I would like to be able to define schedules with the ISO 8601 recurrence format but only need to generate instances for a given period.
Yes, it is possible but you have to introduce your own customizable condition to stop the infinite loop or stream. Example:
Output:
However, infinite iterating requires special care how to model the stop condition and only exist in the class
IsoRecurrencebecause the ISO-8601-standard has explicitly allowed this option. I hope that your ISO-expression (which is to be parsed) is not too wide in range because excessive iterating over many intervals should be avoided for sake of performance.In case you only have daily intervals when the time of day is irrelevant, I recommend to use the type DateInterval.