Replacement for {@link java.lang.String#format(String, Object...)}. All arguments will be
put into the model having their index starting from 1 as their name.

@param pattern
the template
@param args
any number of arguments
@return the expanded template
545883
public synchronized String format(final String pattern, final Object... args) {
		Map<String, Object> model = Collections.emptyMap();
		ModelAdaptor modelAdaptor = new ModelAdaptor() {

			@Override
			public Object getValue(TemplateContext context, Token token, List<String> segments, String expression) {
				int index = Integer.parseInt(expression) - 1;
				return args[index];
			}

            @Override
            public Iterable<Object> getIterable(Object value) {
                return null;
            }

            @Override
            public String getSpecialIteratorVariable() {
                return null;
            }

        };

		String output = transformInternal(pattern, null, model, modelAdaptor, null);
		return output;
	}
75145
public static String format(String templet, Object... args) {
        return MessageFormat.format(templet, args);
    }
711347
private static String patternToString(@Nullable final Pattern pattern) {
		return pattern != null ? pattern.pattern() + " (flags: " + pattern.flags() + ")" : NO_PATTERN_PLACEHOLDER;
	}
737817
protected String internalFormatMessage(String pattern, Object[] args) {
        /* todo: perf -- could the MessageFormat objects be cached? */
        MessageFormat format = new MessageFormat(pattern);
        String msg = format.format(args).toString();
        return msg;
    }
1228738
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);
  }
986061
static String format(String template, Object... args) {
        template = String.valueOf(template); // null -> "null"

        if (N.isNullOrEmpty(args)) {
            return template;
        }

        // start substituting the arguments into the '%s' placeholders
        final StringBuilder sb = Objectory.createStringBuilder(template.length() + 16 * args.length);
        int templateStart = 0;
        int i = 0;

        String placeholder = "{}";
        int placeholderStart = template.indexOf(placeholder);

        if (placeholderStart < 0) {
            placeholder = "%s";
            placeholderStart = template.indexOf(placeholder);
        }

        while (placeholderStart >= 0 && i < args.length) {
            sb.append(template, templateStart, placeholderStart);
            sb.append(N.toString(args[i++]));
            templateStart = placeholderStart + 2;
            placeholderStart = template.indexOf(placeholder, templateStart);
        }

        sb.append(template, templateStart, template.length());

        // if we run out of placeholders, append the extra args in square braces
        if (i < args.length) {
            sb.append(" [");
            sb.append(N.toString(args[i++]));
            while (i < args.length) {
                sb.append(", ");
                sb.append(N.toString(args[i++]));
            }
            sb.append(']');
        }

        final String result = sb.toString();

        Objectory.recycle(sb);

        return result;
    }
186578
public static String format(final Date date, final String pattern) {
        return format(date, pattern, null, null);
    }
1246716
public static String formatDouble(final Double amount, String pattern) {
		if (pattern == null || pattern.equals("")) {
			pattern = JKFormatUtil.DEFAULT_DOUBLE_FORMAT;
		}
		return JKFormatUtil.getNumberFormatter(pattern).format(amount);
	}
253606
public static String format(String templateMessage, Object... args) throws TechnicalException {
        if (null != templateMessage && countWildcardsOccurrences(templateMessage, "%s") == args.length) {
            try {
                return String.format(templateMessage, args);
            } catch (final Exception e) {
                throw new TechnicalException(getMessage(FAIL_MESSAGE_FORMAT_STRING), e);
            }
        } else {
            throw new TechnicalException(getMessage(FAIL_MESSAGE_FORMAT_STRING));
        }
    }
81646
private static String adopt2JavaPattern(String pattern)
   {
      pattern = normalizePath(pattern);

      // any character except '/', one or more times
      pattern = pattern.replaceAll("\\" + ANY_NAME, "[^/]+");

      // any character except '/' exactly one time
      pattern = pattern.replaceAll(ANY_CHAR, "[^/]{1}");

      return pattern;
   }
770838
public String format(String format)
    {
        Matcher m = REF.matcher(format);
        StringBuffer sb = new StringBuffer();
        while (m.find())
        {
            Object ob = get(m.group(1));
            if (ob != null)
            {
                m.appendReplacement(sb, ob.toString());
            }
            else
            {
                m.appendReplacement(sb, m.group());
            }
        }
        m.appendTail(sb);
        return sb.toString();
    }
910374
public static String format(Date date, String pattern) {
		return new DateTime(date.getTime()).toString(pattern);
	}
561111
public static StringTemplate stringTemplate(Template template, Object... args) {
        return stringTemplate(template, ImmutableList.copyOf(args));
    }
824247
@Transformer(requireTemplate = true)
    public static String format(Number number, String pattern, Locale locale) {
        return format(null, number, pattern, locale);
    }
416247
public static String format(final Object object, final String pattern) {
		if (object instanceof Date) {
			return JKFormatUtil.formatDate((Date) object, pattern);
		}
		if (object instanceof Time) {
			return JKFormatUtil.formatTime((Time) object, pattern);
		}
		if (object instanceof Timestamp) {
			return JKFormatUtil.formatTimeStamp((Timestamp) object, pattern);
		}
		if (object instanceof java.util.Date) {
			return JKFormatUtil.formatDate((java.util.Date) object, pattern);
		}
		if (object instanceof Double) {
			return JKFormatUtil.formatDouble((Double) object, pattern);
		}
		if (object != null) {
			return object.toString();
		}
		return null;
	}
923459
public String format(Object expression, Object objPattern) {
        if (objPattern instanceof String) {
            final String pattern = filterPattern((String) objPattern);
            if (expression == null) {
                return null;
            }
            if (expression instanceof LocalDate) {
                return create((LocalDate) expression).toDisp(pattern);
            }
            if (expression instanceof LocalDateTime) {
                return create((LocalDateTime) expression).toDisp(pattern);
            }
            if (expression instanceof java.util.Date) {
                return create((java.util.Date) expression).toDisp(pattern);
            }
            if (expression instanceof String) {
                return create((String) expression).toDisp(pattern);
            }
            String msg =
                    "First argument as two arguments should be LocalDate or LocalDateTime or Date or String(expression): " + expression;
            throw new TemplateProcessingException(msg);
        }
        String msg = "Second argument as two arguments should be String(pattern): objPattern=" + objPattern;
        throw new TemplateProcessingException(msg);
    }
713291
public static String format(final LocalDateTime self, String pattern) {
        return self.format(DateTimeFormatter.ofPattern(pattern));
    }