String (@NotNull String modifier, @Nullable String widthAndPrecision, @Nullable String conversionChar) { final StringBuilder result = new StringBuilder(); // in strict order if (has(modifier, '-')) { result.append("<"); // left align } else if ("s".equals(conversionChar) && !StringUtil.isEmptyOrSpaces(widthAndPrecision)) { // "%20s" aligns right, "{0:20s}" aligns left; to preserve align, make it explicit result.append(">"); } if (has(modifier, '+')) { result.append("+"); // signed } else if (has(modifier, ' ')) result.append(" "); // default-signed if (has(modifier, '#')) result.append("#"); // alt numbers if (has(modifier, '0')) result.append("0"); // padding // anything else can't be here return result.toString(); }