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

IntegeraddDouble(Integer i, Double d)
add Double
if (d == null && i == null) {
    return null;
} else if (d == null && i != null) {
    return i;
} else if (d != null && i == null) {
    return Integer.valueOf(integerFormatter.format(d));
} else {
    return i + Integer.valueOf(integerFormatter.format(d));
...
Doubleadjust(Double lng, Double lat, Double distance, Double angle)
adjust
double dx = distance * 1000 * Math.sin(angle * Math.PI / 180);
double dy = distance * 1000 * Math.cos(angle * Math.PI / 180);
double lon1 = (dx / Ed(lat) + rad(lng)) * 180 / Math.PI;
double lat1 = (dy / Ec(lat) + rad(lat)) * 180 / Math.PI;
if (angle == 0 || angle == 180) {
    return Double.parseDouble(df.format(lat1));
} else {
    return Double.parseDouble(df.format(lon1));
...
DoubleadjustDoubleNumber(Double doubleNumber, int maxIntPart, int maxFloatPart)
adjust Double Number
NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault());
numberFormat.setMaximumFractionDigits(maxFloatPart);
numberFormat.setMaximumIntegerDigits(maxIntPart);
numberFormat.setMinimumFractionDigits(maxFloatPart);
try {
    doubleNumber = numberFormat.parse(numberFormat.format(doubleNumber)).doubleValue();
} catch (ParseException e) {
    new RuntimeException("The adjustDecimalNumber method haved an exception", e);
...
StringcreateMeanRmsString(double values[])
creates a predefined string, that contains useful statistical information.
double mean = calcMean(values);
double rms = calcRms(values);
double meanrms = calcStandardDeviation(values, mean);
String outString = "rms=" + formatter.format(rms) + "; mean=" + formatter.format(mean) + ";  stddev="
        + formatter.format(meanrms);
return outString;
Stringdecimal2percent(double decimal, int pos)
decimalpercent
NumberFormat nt = NumberFormat.getPercentInstance();
nt.setMinimumFractionDigits(pos);
return nt.format(decimal);
Stringdecimal2string(BigDecimal arg, Locale loc)
decimalstring
if (arg == null)
    return null;
return NumberFormat.getInstance(loc).format(arg);
StringdecimalConversation(double amount)
decimal Conversation
NumberFormat formatter = new DecimalFormat("#0.00");
return formatter.format(amount);
DecimalFormatdecimalFormat()
decimal Format
return decimalFormat(false);
StringdecimalFormat(double d)
decimal Format
java.text.DecimalFormat DF = new java.text.DecimalFormat("#,##0.00", new DecimalFormatSymbols(Locale.US));
return DF.format(d);
StringdecimalFormat(double no)
decimal Format
DecimalFormat df = new DecimalFormat("######.##");
String val = df.format(no);
int index = val.indexOf(".");
if (index == -1)
    val = val + ".00";
else {
    if (val.substring(index + 1, val.length()).length() - 1 == 0)
        val = val + "0";
...