Java Utililty Methods Double Number Format

List of utility methods to do Double Number Format

Description

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

Method

booleanisDoubleWhitFormat(String pValue)
is Double Whit Format
try {
    if (!pValue.equals("")) {
        java.text.DecimalFormat formatDecimal = new java.text.DecimalFormat("###,##0.00");
        java.text.DecimalFormatSymbols symbols = new java.text.DecimalFormatSymbols();
        symbols.setGroupingSeparator(',');
        symbols.setDecimalSeparator('.');
        formatDecimal.setDecimalFormatSymbols(symbols);
        double valor = formatDecimal.parse(pValue).doubleValue();
...
StringprettyDecimalFormat(double d, int numPlaces)
pretty Decimal Format
StringBuilder sb = new StringBuilder("#.");
for (int i = 0; i < numPlaces; i++) {
    sb.append("#");
DecimalFormat dFormat = new DecimalFormat(sb.toString());
return dFormat.format(d);
StringroundFormat(double d, int i)
round Format
String num = null;
if (i == 1) {
    num = "0.0";
if (i == 2) {
    num = "0.00";
if (i == 3) {
...
Stringshorten(double num)
shorten
String string = Double.toString(num);
if (Integer.parseInt(string.split("\\.")[1]) == 0) {
    return string.split("\\.")[0];
} else {
    DecimalFormat format = new DecimalFormat("0.##");
    return format.format(num);
doubletoDoubleFromHumanFormat(String doubleAsString)
to Double From Human Format
NumberFormat formatter = NumberFormat.getInstance();
return formatter.parse(doubleAsString).doubleValue();
StringtoString(double in, String format)
to String
DecimalFormat formatter = new DecimalFormat(format);
return formatter.format(in);
StringtoString(double[] arr, NumberFormat nf)
Copies the given array, using a standard scientific notation number formatter and beginning each line with the given lineInit.
String result;
if (nf == null) {
    throw new NullPointerException("NumberFormat must not be null.");
if (arr == null) {
    result = nullMessage();
} else {
    StringBuilder buf = new StringBuilder();
...
StringtoString(double[] y, Format format)
to String
StringBuffer sb = new StringBuffer();
for (int i = 0; i < y.length - 1; i++) {
    sb.append(format.format(y[i]) + " ");
sb.append(format.format(y[y.length - 1]) + " ");
return sb.toString();