private void addPattern ( MethodSpec . Builder method , String pattern ) { // Parse the pattern and populate the method body with instructions to format the date. for ( Node node : DATETIME_PARSER . parse ( pattern ) ) { if ( node instanceof Text ) { method . addStatement ( "b.append($S)" , ( ( Text ) node ) . text ( ) ) ; } else if ( node instanceof Field ) { Field field = ( Field ) node ; method . addStatement ( "formatField(d, '$L', $L, b)" , field . ch ( ) , field . width ( ) ) ; } } }
Add a named date - time pattern adding statements to the formatting and indexing methods . Returns true if the pattern corresponds to a date ; false if a time .