[JAVA] Standard API for string format

String.format

String#format.java


String formated = String.format("I%s.", "Taro");

MassageFormat#format

Message#format.java


String template = "I{0}is.";
String formated = MessageFormat.format(template, "Taro");

performance

Massage Format is much faster.

API 10,Run 000 times 100,Run 000 times
String#format 0.2269983S 1.2679988S
Message#format 0.0730008S 0.2999999S

Recommended Posts

Standard API for string format
Translated JavaDoc for Servlet API 4.0.
Is String # format (String, Object ...) really slow?
Memo for making Niconico API (Materials)
[JSR-310 Date and Time API] Precautions for format definition when converting from Japanese calendar character string to date type