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

Stringformat(final long l)
Formats a number.
final StringBuffer s = new StringBuffer();
return FORMAT_LONG.format(l, s, new java.text.FieldPosition(0)).toString();
Stringformat(final long value, final long divider, final String unit)
format
final double result = divider > 1 ? (double) value / (double) divider : (double) value;
return new DecimalFormat("#,##0.#").format(result) + " " + unit;
Stringformat(Integer num)
format
String result = "";
try {
    result = format((double) num);
} catch (Exception e) {
return result;
Stringformat(long bytes)
format
double val = bytes;
int mag = 0;
while (val > 1024) {
    val = val / 1024;
    mag++;
String formatted = MEM_FMT.format(val);
switch (mag) {
...
Stringformat(long value)
format
return format.format(value);
Stringformat(Number value)
format
return format(value, DEFAULT_NUMBER_FORMAT);
Stringformat(Number value)
format
return format(value, DEFAULT_PATTERN);
Stringformat(Object num, int dev, String valueIfZero)
format
if (num == null) {
    return valueIfZero;
if (dev == 0) {
    dev = 1;
double f = Double.parseDouble(num.toString());
f = f / dev;
...
Stringformat(Object price)
format
DecimalFormat formatter = new DecimalFormat("###,###,##0.00");
return formatter.format(price);
doubleformat(String str_number, int digits)
relation fuction to Currency format
String formatted = Util.format("1234.67789", 2);
formatted ==> "1234.68"
String pattern = "###.";
double value = -1.;
for (int i = 0; i < digits; i++) {
    pattern += "#";
try {
    value = Double.parseDouble(str_number);
} catch (NumberFormatException e) {
...