public static IsoRecurrence<MomentInterval> parseMomentIntervals(String iso)
        throws ParseException {

        String[] parts = iso.split("/");
        int count = parseCount(parts);
        boolean infinite = false;

        if (count == INFINITE) {
            count = 0;
            infinite = true;
        }

        IsoRecurrence<MomentInterval> recurrence;

        if (parts[2].charAt(0) == 'P') {
            boolean extended = isExtendedFormat(parts[1]);
            ZonalDateTime zdt = ZonalDateTime.parse(parts[1], momentFormatter(extended));
            Duration<?> duration = Duration.parsePeriod(parts[2]);
            recurrence = IsoRecurrence.of(count, zdt.toMoment(), duration, zdt.getOffset());
        } else if (parts[1].charAt(0) == 'P') {
            Duration<?> duration = Duration.parsePeriod(parts[1]);
            boolean extended = isExtendedFormat(parts[2]);
            ZonalDateTime zdt = ZonalDateTime.parse(parts[2], momentFormatter(extended));
            recurrence = IsoRecurrence.of(count, duration, zdt.toMoment(), zdt.getOffset());
        } else {
            String remainder = iso.substring(getFirstSlash(iso) + 1);
            MomentInterval interval = MomentInterval.parseISO(remainder);
            Moment start = interval.getStart().getTemporal();
            Moment end = interval.getEnd().getTemporal();
            ZonalOffset offset = null;
            int signIndex = -1;
            for (int i = 1, n = remainder.length(); i < n; i++) {
                char c = remainder.charAt(i);
                if (c == 'Z') {
                    offset = ZonalOffset.UTC;
                    break;
                } else if ((c == '-') || (c == '+')) {
                    signIndex = i;
                } else if (c == '/') {
                    remainder = remainder.substring(signIndex, i);
                    if (remainder.charAt(3) != ':') {
                        remainder = remainder.substring(0, 3) + ":" + remainder.substring(3);
                    }
                    offset = ZonalOffset.parse(remainder);
                    break;
                }
            }
            recurrence = IsoRecurrence.of(count, start, end, offset);
        }

        if (infinite) {
            recurrence = recurrence.withInfiniteCount();
        }

        return recurrence;

    }
public static IsoRecurrence < MomentInterval > parseMomentIntervals ( String iso ) throws ParseException { String [ ] parts = iso . split ( "/" ) ; int count = parseCount ( parts ) ; boolean infinite = false ; if ( count == INFINITE ) { count = 0 ; infinite = true ; } IsoRecurrence < MomentInterval > recurrence ; if ( parts [ 2 ] . charAt ( 0 ) == 'P' ) { boolean extended = isExtendedFormat ( parts [ 1 ] ) ; ZonalDateTime zdt = ZonalDateTime . parse ( parts [ 1 ] , momentFormatter ( extended ) ) ; Duration < ? > duration = Duration . parsePeriod ( parts [ 2 ] ) ; recurrence = IsoRecurrence . of ( count , zdt . toMoment ( ) , duration , zdt . getOffset ( ) ) ; } else if ( parts [ 1 ] . charAt ( 0 ) == 'P' ) { Duration < ? > duration = Duration . parsePeriod ( parts [ 1 ] ) ; boolean extended = isExtendedFormat ( parts [ 2 ] ) ; ZonalDateTime zdt = ZonalDateTime . parse ( parts [ 2 ] , momentFormatter ( extended ) ) ; recurrence = IsoRecurrence . of ( count , duration , zdt . toMoment ( ) , zdt . getOffset ( ) ) ; } else { String remainder = iso . substring ( getFirstSlash ( iso ) + 1 ) ; MomentInterval interval = MomentInterval . parseISO ( remainder ) ; Moment start = interval . getStart ( ) . getTemporal ( ) ; Moment end = interval . getEnd ( ) . getTemporal ( ) ; ZonalOffset offset = null ; int signIndex = - 1 ; for ( int i = 1 , n = remainder . length ( ) ; i < n ; i ++ ) { char c = remainder . charAt ( i ) ; if ( c == 'Z' ) { offset = ZonalOffset . UTC ; break ; } else if ( ( c == '-' ) || ( c == '+' ) ) { signIndex = i ; } else if ( c == '/' ) { remainder = remainder . substring ( signIndex , i ) ; if ( remainder . charAt ( 3 ) != ':' ) { remainder = remainder . substring ( 0 , 3 ) + ":" + remainder . substring ( 3 ) ; } offset = ZonalOffset . parse ( remainder ) ; break ; } } recurrence = IsoRecurrence . of ( count , start , end , offset ) ; } if ( infinite ) { recurrence = recurrence . withInfiniteCount ( ) ; } return recurrence ; }
/*[deutsch]
<p>Interpretiert einen Text wie &quot;R5/2016-04-01T10:45Z/30T23:59&quot;
als eine Sequenz von wiederkehrenden Moment-Intervallen. </p>

<p>Unterst&uuml;tzte ISO-Formate f&uuml;r Zeitstempelkomponenten sind
{@link Iso8601Format#BASIC_DATE_TIME_OFFSET} und {@link Iso8601Format#EXTENDED_DATE_TIME_OFFSET}.
Eine Dauerkomponente wird mittels {@link Duration#parsePeriod(String)} interpretiert. </p>

@param   iso     canonical representation of recurrent intervals
@return  parsed sequence of recurrent half-open moment intervals
@throws  ParseException in any case of inconsistencies