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

StringformatIntoCurr(String str_number, int digits)
Use this method like this:
String formatted = Util.formatIntoCurr("123456789.123", 2);
formatted ==> "123,456,789.12"
String pattern = "###,###";
double value = -1.;
if (digits > 0)
    pattern += ".";
for (int i = 0; i < digits; i++) {
    pattern += "#";
try {
...
StringformatLong(long value)
format Long
NumberFormat formatter = new DecimalFormat("#,###,###");
return formatter.format(value);
StringformatNumber(final long number)
format Number
DecimalFormat f = new DecimalFormat("#,###");
return f.format(number);
StringformatNumber(final long number)
format Number
DecimalFormat f = new DecimalFormat("#,###");
return f.format(number);
StringformatNumber(int num)
format Number
return intFormat_.format(num);
StringformatNumber(int source)
format Number
String pattern = "###,###";
DecimalFormat decimalFormat = new DecimalFormat(pattern);
String format = decimalFormat.format(source);
return format;
StringformatNumber(long number)
format Number
return numberFormat.format(number);
StringformatNumber(long number)
Formats a number, as a decimal number with at most 2 digits.
return DECIMAL.format(number);
StringformatNumber(Number num)
format Number
return formatNumber(num, DEFAULT_NUMBER_FORMAT);
StringformatNumber(Number number)
Examples: 1 -> 1 12d -> 12 123d -> 123 1234d -> 1.234E03 12345d -> 12.345E03 123.1234567890d -> 123.123457 1234.1234567890d -> 1.23412346E03 1.12345678901234567890d -> 1.12345679 12345.1234567890d -> 12.3451235E03 0.000000000001234567890d -> 1.23456789E-12
return nf.get().format(number).replace("E00", "");