code: public static String format(String formatString, Object... args) {
      // Rewrites the varargs so that objects that need special formatting are
      // replaced with formatted strings, then hands off to {@link String#format}.
  
      Object[] formattedArgs = new Object[args.length];
      for (int i = 0; i < args.length; ++i) {
        formattedArgs[i] = formatObject(args[i]);
      }
  
      return String.format(formatString, (Object[]) formattedArgs);
    }
docs: Generate a string based on a format template as {@link String#format}
  would, using the pretty-printing rules specified in the class
  documentation.