Yes, it is possible but you have to introduce your own customizable condition to stop the infinite loop or stream. Example:
@Test
public void parseInfiniteTimestampIntervals() throws ParseException {
IsoRecurrence<TimestampInterval> intervals =
IsoRecurrence.parseTimestampIntervals("R/2019-01-01T00:00:00/P1D");
PlainDate start = PlainDate.of(2019, 6, 11);
PlainDate end = PlainDate.of(2019, 6, 15);
for (TimestampInterval interval : intervals) {
PlainDate current = interval.getStartAsTimestamp().getCalendarDate();
if (current.isAfterOrEqual(start)) {
if (current.isBeforeOrEqual(end)) {
System.out.println(interval); // or do your own stuff with the current interval
} else {
break; // end of infinite loop
}
}
}
}
Output:
[2019-06-11T00/2019-06-12T00)
[2019-06-12T00/2019-06-13T00)
[2019-06-13T00/2019-06-14T00)
[2019-06-14T00/2019-06-15T00)
[2019-06-15T00/2019-06-16T00)
However, infinite iterating requires special care how to model the stop condition and only exist in the class IsoRecurrence
because 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.