5
I have a canvas on which I work with the monetary value masks of jQuery Mask, when the user performs the Submit of form the value returned to my controller is Ex:. 1.340,34.
The attribute in my Bean that the bind is a Bigdecimal. Soon I had to create a Customnumbereditor and register it in a @Initbinder as shown below:
@InitBinder
public void initBigDecimalBinder(WebDataBinder binder) throws Exception {
DecimalFormat df = new DecimalFormat();
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setGroupingSeparator('.');
dfs.setDecimalSeparator(',');
df.setDecimalFormatSymbols(dfs);
binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, df, true));
}
The Biggest problem is that the values are not correct, ie the example number right above is 1340 in the database, and the right one would be 1.340.34.
How can I perform such a conversion correctly?
João, your doubt helped me a lot, adjusting the accuracy via note solved my problem
– Thiago Pereira