String rightStr = str.substring(separator + 1);
if (rightStr.length() <= 0) {
throw new IllegalArgumentException("Format invalid: " + str);
}
DateTimeFormatter dateTimeParser = ISODateTimeFormat.dateTimeParser();
dateTimeParser = dateTimeParser.withChronology(chrono);
PeriodFormatter periodParser = ISOPeriodFormat.standard();
long startInstant = 0, endInstant = 0;
Period period = null;
Chronology parsedChrono = null;
// before slash
char c = leftStr.charAt(0);
if (c == 'P' || c == 'p') {
period = periodParser.withParseType(getPeriodType(leftStr)).parsePeriod(leftStr);
} else {
DateTime start = dateTimeParser.parseDateTime(leftStr);
startInstant = start.getMillis();
parsedChrono = start.getChronology();
}
// after slash
c = rightStr.charAt(0);
if (c == 'P' || c == 'p') {
if (period != null) {
throw new IllegalArgumentException("Interval composed of two durations: " + str);
}
period = periodParser.withParseType(getPeriodType(rightStr)).parsePeriod(rightStr);
chrono = (chrono != null ? chrono : parsedChrono);
endInstant = chrono.add(period, startInstant, 1);
} else {
DateTime end = dateTimeParser.parseDateTime(rightStr);
endInstant = end.getMillis();
parsedChrono = (parsedChrono != null ? parsedChrono : end.getChronology());
chrono = (chrono != null ? chrono : parsedChrono);
if (period != null) {
startInstant = chrono.add(period, endInstant, -1);