Java Utililty Methods Number Format Pattern

List of utility methods to do Number Format Pattern

Description

The list of methods to do Number Format Pattern are organized into topic(s).

Method

StringformatDisplay(String displayString)
format Display
return DECIMAL_FORMAT.format(Double.valueOf(displayString));
StringformatDollar(Object obj)
format Dollar
if (obj == null) {
    return "";
BigDecimal bd = (BigDecimal) obj;
try {
    DecimalFormat intFormat = new DecimalFormat("$###,###,###,##0.00");
    return intFormat.format(bd);
} catch (Exception e) {
...
StringformatDollarTd(Object obj)
format Dollar Td
String out = "<td style='text-align:right'>";
String strDollarAmt = formatDollar(obj);
if (strDollarAmt.length() == 0) {
    out += "&nbsp;";
} else {
    out += strDollarAmt;
out += "</td>";
...
StringformatFileLength(long length)
Returns a nicer representation of the number as a file length.
DecimalFormat format = new DecimalFormat("###0.##");
double num = length;
String unit;
if (length < KBYTE) {
    unit = "B";
} else if (length < MBYTE) {
    num /= KBYTE;
    unit = "KB";
...
StringformatGopNumber(Number gop)
format Gop Number
DecimalFormat df = new DecimalFormat("######0.000");
df.setRoundingMode(RoundingMode.DOWN);
return df.format(gop);
StringformatI18N(Object ob)
format IN
if (ob == null) {
    return "";
Double value = toDouble(ob, null);
if (value == null) {
    return "";
value = round(value, 4);
...
StringformatiereSpeichergroesse(long bytes)
formatiere Speichergroesse
if (bytes < 0)
    return "0 Byte";
if (bytes < 1024)
    return "" + bytes + " Byte";
double b = bytes / 1024.;
if (b < 1024.)
    return DF_2.format(b) + " KByte";
return DF_2.format(b / 1024.) + " MByte";
...
StringformatIncludeCommas(final Number object)
Format numbers for display as comma separated groups.
if (object == null) {
    return "";
return NUMBER_FORMATTER.format(object);
StringformatInt(final int number)
Format a 'int' number with default pattern
String result = null;
DecimalFormat df = new DecimalFormat(INTEGER_PATTERN);
try {
    result = df.format(number);
} catch (ArithmeticException ae) {
return result;
StringformatInteger(Object obj)
format Integer
if (obj == null) {
    return "";
} else {
    try {
        Integer ival = (Integer) obj;
        DecimalFormat intFormat = new DecimalFormat("###,###,###,##0");
        return intFormat.format(ival);
    } catch (Exception e) {
...