Java Utililty Methods Decimal Format

List of utility methods to do Decimal Format

Description

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

Method

DoublegetDoubleByNumeric(String valorTexto)
get Double By Numeric
NumberFormat df = DecimalFormat.getInstance(localBrasil);
return df.parse(valorTexto).doubleValue();
StringgetDoubleDecimalNumber(double d)
get Double Decimal Number
return decimalFormat.format(d);
doublegetDoubledigit(double f)
get Doubledigit
DecimalFormat df = new DecimalFormat("#####.00");
return Double.parseDouble(df.format(f));
StringgetDoubleForDisplay(Double d)
get Double For Display
if (d == null) {
    return "";
} else if (d == 0) {
    return "";
} else {
    return df.format(d);
doublegetDoubleFromTaxSet(String taxSetValue)
get double value from arbitrary String represent a double (0,00) or (0.00)
NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN);
DecimalFormat decimalFormat = (DecimalFormat) nf;
Exception parseException;
try {
    return decimalFormat.parse(taxSetValue).doubleValue();
} catch (ParseException ignored) {
nf = NumberFormat.getNumberInstance(Locale.US);
...
doublegetDoubleWithTwoDecimalDigits(double value)
get Double With Two Decimal Digits
DecimalFormat df = new DecimalFormat("0.00", new DecimalFormatSymbols(Locale.US));
return Double.valueOf(df.format(value));
StringgetDurationString(double duration)
get Duration String
return df.format(duration) + "s";
StringgetEngineeringNotation(final double d)
get Engineering Notation
final String engineeringNotation = engineeringFormat.format(d);
if (engineeringNotation.endsWith(E0)) {
    return engineeringNotation.substring(0, engineeringNotation.length() - E0.length());
return engineeringNotation;
IntegergetInteger(Double d)
get Integer
if (d == null) {
    return null;
} else {
    return Integer.valueOf(integerFormatter.format(d));
intgetIntNum(Double value)
get Int Num
DecimalFormat df = new DecimalFormat("#");
String str = df.format(value).replaceAll("-", "");
return str.length();