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

Stringformat_mm_ss(final long time)
formamss
_sbFormatter.setLength(0);
if (time < 0) {
    _sbFormatter.append(SYMBOL_DASH);
final long timeAbsolute = time < 0 ? 0 - time : time;
return _formatter.format(FORMAT_MM_SS, 
        (timeAbsolute / 60), (timeAbsolute % 60)).toString();
StringformatLong(long number, int length)
format Long
StringBuffer sb = new StringBuffer();
Formatter f = new Formatter(sb);
f.format("%,d", number);
return padLeft(sb.toString(), length);
ExceptionformatMessageException(String format, Object... args)
format Message Exception
StringBuilder mes = new StringBuilder();
Formatter f = new Formatter(mes);
f.format(format, args);
f.close();
return new Exception(mes.toString());
StringformatNumber(int number)
This returns a formatted string that shows the number based on the locale turns 1000 into 1,000
StringBuilder str = new StringBuilder();
Formatter f = new Formatter(str, Locale.getDefault());
f.format("%,d", number);
return str.toString();
voidformatResponse(Formatter formatter, String response)
format Response
formatter.format("  > %100s <\n", response);
StringformatTzname(final String format, final String letter)
format Tzname
if (!format.contains("%")) {
    return format;
final Formatter f = new Formatter();
final String param;
if (letter.equals("-")) {
    param = "";
} else {
...
Stringformatv(String format, Object[] args)
Returns a string from a format string and its argument.
if (args == null || args.length == 0)
    return format;
synchronized (g_formatter) {
    g_formatter.format(format, args);
    g_formatter.flush();
    StringBuilder s = (StringBuilder) (g_formatter.out());
    String ans = s.toString();
    s.delete(0, s.length());
...
StringformatZeroDecimals(Number x)
format Zero Decimals
return new Formatter().format("%,.0f", x == null ? Double.NaN : x.doubleValue()).toString();
Stringfperfdata(String label, double val, String uom, int warnp, double warn, int critp, double crit, boolean minp, double minv, boolean maxp, double maxv)
fperfdata
Formatter f = new Formatter(new StringBuffer());
if (label.matches("['= ]"))
    f.format("'%s'=", label);
else
    f.format("%s=", label);
f.format("%f", val);
f.format("%s;", uom);
if (warnp != 0)
...
StringgenerateMacOnIncrease(final String baseMac, final long l)
generate Mac On Increase
long mac = mac2Long(baseMac);
if (l > 0xFFFFl) {
    return null;
mac = mac + (l << 24);
mac = mac & 0x06FFFFFFFFFFl;
return long2Mac(mac);