Here you can find the source of substitution(Formatter formatter, int flags, int width, int precision, StringBuilder obj)
public static void substitution(Formatter formatter, int flags, int width, int precision, StringBuilder obj)
//package com.java2s; //License from project: Mozilla Public License import java.util.FormattableFlags; import java.util.Formatter; public class Main { public static void substitution(Formatter formatter, int flags, int width, int precision, StringBuilder obj) { StringBuilder sb = new StringBuilder(obj.length()); if (precision == -1 || obj.length() < precision) { sb.append(obj.toString());//from w w w .j a v a 2 s .c o m } else { sb.append(obj.substring(0, precision - 3)).append("..."); } final int L = sb.length(); if (L < width) { for (int i = 0; i < width - L; i++) { if ((flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY) { sb.append(' '); } else { sb.insert(0, ' '); } } } formatter.format(sb.toString()); } }