Added java.util.Formatter implementation. Basic/common formats work,

such as %s, %d, %x... also width, left justify, zerofill flags are
implemented. Many of the other formats do not work, see the comments in
avian.FormatString javadoc and look for FIXME and TODO items for more
information on features that are known to not work correctly.
This commit is contained in:
BCG
2015-03-15 00:28:45 -04:00
parent cacc099987
commit a8bed52097
7 changed files with 1544 additions and 1 deletions

View File

@ -13,6 +13,7 @@ package java.lang;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Comparator;
import java.util.Formatter;
import java.util.Locale;
import java.util.regex.Pattern;
@ -574,6 +575,20 @@ public final class String
public native String intern();
public static String format(String fmt, Object... args) {
final Formatter formatter = new Formatter();
final String result = formatter.format(fmt, args).toString();
formatter.close();
return result;
}
public static String format(Locale l, String fmt, Object... args) {
final Formatter formatter = new Formatter();
final String result = formatter.format(l, fmt, args).toString();
formatter.close();
return result;
}
public static String valueOf(Object s) {
return s == null ? "null" : s.toString();
}