Java Utililty Methods Number Add

List of utility methods to do Number Add

Description

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

Method

Stringadd(String number1, String number2)
add
BigDecimal bd = new BigDecimal(number1);
return bd.add(new BigDecimal(number2)).toString();
Tadd(T a, T b)
add
if (a instanceof Integer) {
    return (T) new Integer((Integer) a + (Integer) b);
if (a instanceof Long) {
    return (T) new Long((Long) a + (Long) b);
if (a instanceof Double) {
    return (T) new Double((Double) a + (Double) b);
...
Doubleadd1(Double v1, Double v2)
add
if (v1 == null) {
    v1 = 0d;
if (v2 == null) {
    v2 = 0d;
double s1 = v1, s2 = v2;
double v = add(s1, s2);
...
doubleadd4Money(Double value1, Double value2)
add Money
return getScaleValue4Money(defaultValue(value1).doubleValue() + defaultValue(value2).doubleValue());
doubleaddAmounts(final double num1, final double num2)
Adds the amounts.
final BigDecimal b1 = new BigDecimal(num1);
final BigDecimal b2 = new BigDecimal(num2);
BigDecimal b3 = b1.add(b2);
b3 = b3.setScale(3, BigDecimal.ROUND_HALF_UP);
final double result = b3.doubleValue();
return result;
DoubleaddDoubles(Double value, Double addValue)
add Doubles
BigDecimal sum = BigDecimal.ZERO; 
if (value != null) {
    sum = BigDecimal.valueOf(value);
if (addValue != null) {
    sum = sum.add(BigDecimal.valueOf(addValue));
return sum.doubleValue();
...
StringaddDoubles(String str1, String str2, int rounding)
add two double strings
double d1 = toDouble(str1);
double d2 = toDouble(str2);
double rc = round(d1 + d2, rounding);
return "" + rc;
intDoubleToInt(double d, double multiply, double add)
Double To Int
int result = BigDecimal.valueOf(d).add(BigDecimal.valueOf(add)).multiply(BigDecimal.valueOf(multiply))
        .intValue();
return result;
doublereadDoubleAsString(String doubleAsString)
Method for reading a double value as a string which uses either "," or "."
BigDecimal temp;
try {
    temp = new BigDecimal(doubleAsString);
} catch (NumberFormatException e) {
    doubleAsString = doubleAsString.replaceAll("\\.", "");
    doubleAsString = doubleAsString.replaceAll(",", "\\.");
    try {
        temp = new BigDecimal(doubleAsString);
...