I've used DecimalFormat df = new DecimalFormat("#,###.00");
to format a BigDecimal
.
Now, I want to use that formatted value (say it is '1 250,00') to create new BigDecimal
. I've tried this:
BigDecimal result = new BigDecimal(model.getValue().replace(",",".").replace(" ",""));
But that space
between 1 and 2 in 1 250.00 is not replaced. How can I fix it?
Example:
DecimalFormat df = new DecimalFormat("#,###.00");
BigDecimal example = new BigDecimal("1250");
String str = df.format(example);
System.out.println(str.replace(",",".").replace(" ",""));