private String getBestAppending ( DateTimeMatcher source , int missingFields , DistanceInfo distInfo , DateTimeMatcher skipMatcher , EnumSet < DTPGflags > flags , int options ) { String resultPattern = null ; if ( missingFields != 0 ) { PatternWithMatcher resultPatternWithMatcher = getBestRaw ( source , missingFields , distInfo , skipMatcher ) ; resultPattern = adjustFieldTypes ( resultPatternWithMatcher , source , flags , options ) ; while ( distInfo . missingFieldMask != 0 ) { // precondition: EVERY single field must work! // special hack for SSS. If we are missing SSS, and we had ss but found it, replace the s field according to the // number separator if ( ( distInfo . missingFieldMask & SECOND_AND_FRACTIONAL_MASK ) == FRACTIONAL_MASK && ( missingFields & SECOND_AND_FRACTIONAL_MASK ) == SECOND_AND_FRACTIONAL_MASK ) { resultPatternWithMatcher . pattern = resultPattern ; flags = EnumSet . copyOf ( flags ) ; flags . add ( DTPGflags . FIX_FRACTIONAL_SECONDS ) ; resultPattern = adjustFieldTypes ( resultPatternWithMatcher , source , flags , options ) ; distInfo . missingFieldMask &= ~ FRACTIONAL_MASK ; // remove bit continue ; } int startingMask = distInfo . missingFieldMask ; PatternWithMatcher tempWithMatcher = getBestRaw ( source , distInfo . missingFieldMask , distInfo , skipMatcher ) ; String temp = adjustFieldTypes ( tempWithMatcher , source , flags , options ) ; int foundMask = startingMask & ~ distInfo . missingFieldMask ; int topField = getTopBitNumber ( foundMask ) ; resultPattern = SimpleFormatterImpl . formatRawPattern ( getAppendFormat ( topField ) , 2 , 3 , resultPattern , temp , getAppendName ( topField ) ) ; } } return resultPattern ; }
We only get called here if we failed to find an exact skeleton . We have broken it into date + time and look for the pieces . If we fail to find a complete skeleton we compose in a loop until we have all the fields .