In regex syntax, "$" indicates the end of the string. In your regex, you are trying to remove any character after the end of the string which is not a number or a dot, which won't work, so the "," is never removed from your string, resulting in a conversion error.
You can do this:
new BigDecimal(row1.Trade_Amount.replaceAll("[^\\d.]", ""))
Answer from Ibrahim Mezouar on Stack OverflowVideos
You can use BigDecimal
BigDecimal v1 = new BigDecimal("15.25");
BigDecimal v2 = new BigDecimal("5.25");
BigDecimal v3 = new BigDecimal("1.15");
BigDecimal v123 = v1.divide(v2, MathContext.DECIMAL64).multiply(v3);
System.out.println(v123);
System.out.println(v123.setScale(2, RoundingMode.HALF_UP));
prints
3.34047619047619075
3.34
To perform this calculation using double
double v1 = 15.25;
double v2 = 5.25;
double v3 = 1.15;
double v123 = v1 / v2 * v3;
System.out.println(v123);
System.out.printf("%.2f%n", v123);
prints
3.34047619047619
3.34
If MathContext.DECIMAL128 had been used, the unrounded value would be
3.340476190476190476190476190476191
and in this example, both solutions are more than accurate enough.
Thank you for your answers, I've found the solution: My error while trying to perform above was that I've exported the
new BigDecimal("15.25")
to a .csv file and afterwards put this field into the calculation. Apparently Talend is converting a correctly converted BigDecimal to "15" unless I use a .toString(). So after converting the exemplary "15.25" to BigDecimal and not putting it into .csv file, below formula did the trick
(((v1).multiply(v2)).divide(v3, 2, java.math.RoundingMode.HALF_UP)).toString()
Thank you @peter-lawrey