Implement String.format
*/
package org.teavm.classlib.java.lang;
+import java.util.Locale;
import org.teavm.classlib.java.io.TSerializable;
import org.teavm.classlib.java.io.TUnsupportedEncodingException;
import org.teavm.classlib.java.nio.TByteBuffer;
@@ -23,6 +24,7 @@ import org.teavm.classlib.java.nio.charset.TCharset;
import org.teavm.classlib.java.nio.charset.impl.TUTF8Charset;
import org.teavm.classlib.java.util.TArrays;
import org.teavm.classlib.java.util.TComparator;
+import org.teavm.classlib.java.util.TFormatter;
import org.teavm.classlib.java.util.THashMap;
import org.teavm.classlib.java.util.TMap;
import org.teavm.classlib.java.util.regex.TPattern;
@@ -642,4 +644,12 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
public String replaceFirst(String regex, String replacement) {
return TPattern.compile(regex).matcher(toString()).replaceFirst(replacement);
}
+
+ public static String format(String format, Object... args) {
+ return new TFormatter().format(format, args).toString();
+ }
+
+ public static String format(Locale l, String format, Object... args) {
+ return new TFormatter(l).format(format, args).toString();
+ }
}
