private int parseOffsetFieldsWithPattern ( String text , int start , Object [ ] patternItems , boolean forceSingleHourDigit , int fields [ ] ) { assert ( fields != null && fields . length >= 3 ) ; fields [ 0 ] = fields [ 1 ] = fields [ 2 ] = 0 ; boolean failed = false ; int offsetH , offsetM , offsetS ; offsetH = offsetM = offsetS = 0 ; int idx = start ; int [ ] tmpParsedLen = { 0 } ; for ( int i = 0 ; i < patternItems . length ; i ++ ) { if ( patternItems [ i ] instanceof String ) { String patStr = ( String ) patternItems [ i ] ; int len = patStr . length ( ) ; if ( ! text . regionMatches ( true , idx , patStr , 0 , len ) ) { failed = true ; break ; } idx += len ; } else { assert ( patternItems [ i ] instanceof GMTOffsetField ) ; GMTOffsetField field = ( GMTOffsetField ) patternItems [ i ] ; char fieldType = field . getType ( ) ; if ( fieldType == ' ' ) { int maxDigits = forceSingleHourDigit ? 1 : 2 ; offsetH = parseOffsetFieldWithLocalizedDigits ( text , idx , 1 , maxDigits , 0 , MAX_OFFSET_HOUR , tmpParsedLen ) ; } else if ( fieldType == ' ' ) { offsetM = parseOffsetFieldWithLocalizedDigits ( text , idx , 2 , 2 , 0 , MAX_OFFSET_MINUTE , tmpParsedLen ) ; } else if ( fieldType == ' ' ) { offsetS = parseOffsetFieldWithLocalizedDigits ( text , idx , 2 , 2 , 0 , MAX_OFFSET_SECOND , tmpParsedLen ) ; } if ( tmpParsedLen [ 0 ] == 0 ) { failed = true ; break ; } idx += tmpParsedLen [ 0 ] ; } } if ( failed ) { return 0 ; } fields [ 0 ] = offsetH ; fields [ 1 ] = offsetM ; fields [ 2 ] = offsetS ; return idx - start ; }
Parses localized GMT offset fields with the given pattern