Java Utililty Methods Formatter Usage

List of utility methods to do Formatter Usage

Description

The list of methods to do Formatter Usage are organized into topic(s).

Method

StringdisplayStackTrace()
display Stack Trace
return displayStackTrace(null);
voidecho(Formatter script, String label, String message, String file)
echo
script.format("echo \"#AT_%s %s\" >> %s\n", label, message, file);
StringencodeHex(byte[] bytes)
Converts the given byte array to a Hex formatted string.
Formatter hexStringFormatter = new Formatter();
for (byte b : bytes) {
    hexStringFormatter.format("%02X", b);
return hexStringFormatter.toString();
StringescapeUnicode(String input)
escape Unicode
StringBuilder b = new StringBuilder(input.length());
Formatter f = new Formatter(b);
for (char c : input.toCharArray()) {
    if (c < 128) {
        b.append(c);
    } else {
        f.format("%02X", (int) c);
f.close();
return b.toString();
StringfloatForSql(Float f)
generate a nice string representation of this floating point number suitable for Sql
if (f == null)
    return "NULL";
Formatter fmt = new Formatter();
fmt.format("%.2f", f);
return fmt.toString();
StringFmt(String format, Object... args)
Fmt
return new Formatter().format(format, args).toString();
Stringformat(double value)
Format the given value into a representation with 4 digits after the comma.
return format(value, 4);
Stringformat(Locale l, String format, Object... args)
Returns a formatted string using the specified locale, format string, and arguments.
return new Formatter(l).format(format, args).toString();
Stringformat(String format, Object... args)
format
return format(null, format, args);
Stringformat_hh_mm_ss_Optional(final long value)
formahms Optional
boolean isShowSeconds = true;
final int seconds = (int) ((value % 3600) % 60);
if (isShowSeconds && seconds == 0) {
    isShowSeconds = false;
String valueText;
if (isShowSeconds) {
    valueText = format_hh_mm_ss(value);
...