Buggy code:
public class FastDateFormat extends Format { private static final long serialVersionUID = 1L ; public static final int FULL = DateFormat . FULL ; public static final int LONG = DateFormat . LONG ; public static final int MEDIUM = DateFormat . MEDIUM ; public static final int SHORT = DateFormat . SHORT ; private static String cDefaultPattern ; private static final Map < FastDateFormat , FastDateFormat > cInstanceCache = new HashMap < FastDateFormat , FastDateFormat > ( 7 ) ; private static final Map < Object , FastDateFormat > cDateInstanceCache = new HashMap < Object , FastDateFormat > ( 7 ) ; private static final Map < Object , FastDateFormat > cTimeInstanceCache = new HashMap < Object , FastDateFormat > ( 7 ) ; private static final Map < Object , FastDateFormat > cDateTimeInstanceCache = new HashMap < Object , FastDateFormat > ( 7 ) ; private static final Map < Object , String > cTimeZoneDisplayCache = new HashMap < Object , String > ( 7 ) ; private final String mPattern ; private final TimeZone mTimeZone ; private final boolean mTimeZoneForced ; private final Locale mLocale ; private final boolean mLocaleForced ; private transient FastDateFormat . Rule [ ] mRules ; private transient int mMaxLengthEstimate ; public static FastDateFormat getInstance ( ) { } public static FastDateFormat getInstance ( String pattern ) { } public static FastDateFormat getInstance ( String pattern , TimeZone timeZone ) { } public static FastDateFormat getInstance ( String pattern , Locale locale ) { } public static synchronized FastDateFormat getInstance ( String pattern , TimeZone timeZone , Locale locale ) { } public static FastDateFormat getDateInstance ( int style ) { } public static FastDateFormat getDateInstance ( int style , Locale locale ) { } public static FastDateFormat getDateInstance ( int style , TimeZone timeZone ) { } public static synchronized FastDateFormat getDateInstance ( int style , TimeZone timeZone , Locale locale ) { } public static FastDateFormat getTimeInstance ( int style ) { } public static FastDateFormat getTimeInstance ( int style , Locale locale ) { } public static FastDateFormat getTimeInstance ( int style , TimeZone timeZone ) { } public static synchronized FastDateFormat getTimeInstance ( int style , TimeZone timeZone , Locale locale ) { } public static FastDateFormat getDateTimeInstance ( int dateStyle , int timeStyle ) { } public static FastDateFormat getDateTimeInstance ( int dateStyle , int timeStyle , Locale locale ) { } public static FastDateFormat getDateTimeInstance ( int dateStyle , int timeStyle , TimeZone timeZone ) { } public static synchronized FastDateFormat getDateTimeInstance ( int dateStyle , int timeStyle , TimeZone timeZone , Locale locale ) { } static synchronized String getTimeZoneDisplay ( TimeZone tz , boolean daylight , int style , Locale locale ) { } private static synchronized String getDefaultPattern ( ) { } protected FastDateFormat ( String pattern , TimeZone timeZone , Locale locale ) { } protected void init ( ) { } protected List < FastDateFormat . Rule > parsePattern ( ) { } protected String parseToken ( String pattern , int [ ] indexRef ) { <START_BUG> StringBuffer buf = new StringBuffer ( ) ; <END_BUG> int i = indexRef [ 0 ] ; int length = pattern . length ( ) ; char c = pattern . charAt ( i ) ; if ( ( ( c >= 'A' ) && ( c <= 'Z' ) ) || ( ( c >= 'a' ) && ( c <= 'z' ) ) ) { buf . append ( c ) ; while ( ( i + 1 ) < length ) { char peek = pattern . charAt ( ( i + 1 ) ) ; if ( peek == c ) { buf . append ( c ) ; i ++ ; } else { break ; } } } else { buf . append ( '\'' ) ; boolean inLiteral = false ; for ( ; i < length ; i ++ ) { c = pattern . charAt ( i ) ; if ( c == '\'' ) { if ( ( ( i + 1 ) < length ) && ( ( pattern . charAt ( ( i + 1 ) ) ) == '\'' ) ) { i ++ ; buf . append ( c ) ; } else { inLiteral = ! inLiteral ; } } else if ( ( ! inLiteral ) && ( ( ( c >= 'A' ) && ( c <= 'Z' ) ) || ( ( c >= 'a' ) && ( c <= 'z' ) ) ) ) { i -- ; break ; } else { buf . append ( c ) ; } } } indexRef [ 0 ] = i ; return buf . toString ( ) ; } protected FastDateFormat . NumberRule selectNumberRule ( int field , int padding ) { } @ Override public StringBuffer format ( Object obj , StringBuffer toAppendTo , FieldPosition pos ) { } public String format ( long millis ) { } public String format ( Date date ) { } public String format ( Calendar calendar ) { } public StringBuffer format ( long millis , StringBuffer buf ) { } public StringBuffer format ( Date date , StringBuffer buf ) { } public StringBuffer format ( Calendar calendar , StringBuffer buf ) { } protected StringBuffer applyRules ( Calendar calendar , StringBuffer buf ) { } @ Override public Object parseObject ( String source , ParsePosition pos ) { } public String getPattern ( ) { } public TimeZone getTimeZone ( ) { } public boolean getTimeZoneOverridesCalendar ( ) { } public Locale getLocale ( ) { } public int getMaxLengthEstimate ( ) { } @ Override public boolean equals ( Object obj ) { } @ Override public int hashCode ( ) { } @ Override public String toString ( ) { } private void readObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { }

Fix:
StringBuilder buf = new StringBuilder ( ) ;