Implement String.format

This commit is contained in:
Alexey Andreev 2017-10-30 00:06:25 +03:00
parent 5109691a8d
commit 6d5b4a67e5

View File

@ -15,6 +15,7 @@
*/
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();
}
}