question: protected DateTimeData parse ( String str , int durationType ) throws SchemaDateTimeException { int len = str . length ( ) ; DateTimeData date = new DateTimeData ( str , this ) ; int start = 0 ; char c = str . charAt ( start ++ ) ; if ( c != 'P' && c != '-' ) { throw new SchemaDateTimeException ( ) ; } else { date . utc = ( c == '-' ) ? '-' : 0 ; if ( c == '-' && str . charAt ( start ++ ) != 'P' ) { throw new SchemaDateTimeException ( ) ; } } int negate = 1 ; if ( date . utc == '-' ) { negate = - 1 ; } boolean designator = false ; int endDate = indexOf ( str , start , len , 'T' ) ; if ( endDate == - 1 ) { endDate = len ; } else if ( durationType == YEARMONTHDURATION_TYPE ) { throw new SchemaDateTimeException ( ) ; } int end = indexOf ( str , start , endDate , 'Y' ) ; if ( end != - 1 ) { if ( durationType == DAYTIMEDURATION_TYPE ) { throw new SchemaDateTimeException ( ) ; } date . year = negate * parseInt ( str , start , end ) ; start = end + 1 ; designator = true ; } end = indexOf ( str , start , endDate , 'M' ) ; if ( end != - 1 ) { if ( durationType == DAYTIMEDURATION_TYPE ) { throw new SchemaDateTimeException ( ) ; } date . month = negate * parseInt ( str , start , end ) ; start = end + 1 ; designator = true ; } end = indexOf ( str , start , endDate , 'D' ) ; if ( end != - 1 ) { if ( durationType == YEARMONTHDURATION_TYPE ) { throw new SchemaDateTimeException ( ) ; } date . day = negate * parseInt ( str , start , end ) ; start = end + 1 ; designator = true ; } if ( len == endDate && start != len ) { throw new SchemaDateTimeException ( ) ; } if ( len != endDate ) { end = indexOf ( str , ++ start , len , 'H' ) ; if ( end != - 1 ) { date . hour = negate * parseInt ( str , start , end ) ; start = end + 1 ; designator = true ; } end = indexOf ( str , start , len , 'M' ) ; if ( end != - 1 ) { date . minute = negate * parseInt ( str , start , end ) ; start = end + 1 ; designator = true ; } end = indexOf ( str , start , len , 'S' ) ; if ( end != - 1 ) { date . second = negate * parseSecond ( str , start , end ) ; start = end + 1 ; designator = true ; } if ( start != len || str . charAt ( -- start ) == 'T' ) { throw new SchemaDateTimeException ( ) ; } } if ( ! designator ) { throw new SchemaDateTimeException ( ) ; } return date ; }
target:  Parses, validates and computes normalized version of duration object