I
iksrazal
I need to have a float in brazil format, such as 1,000 (instead of
1.000). I also need to guarantee 7 places after the decimal. The value
is recieved first as a string, avoiding (I hoped) the notorious float
precision problem. I break the strings with ',', and verify with
String.length() on the second part. I get the precision I need with:
Locale locale = new Locale("pt", "BR");
NumberFormat nf = NumberFormat.getInstance(locale);
nf.setMinimumFractionDigits(7);
Number value = nf.parse(_value);
Doing a println() on 'value' verifies I have the correct format.
Except I now need to write it to a database column formated as Decimal
- I cannot give a string to it. Number.floatValue() rounds my numbers
- I need them in the format I got with println()
Any ideas?
iksrazal
1.000). I also need to guarantee 7 places after the decimal. The value
is recieved first as a string, avoiding (I hoped) the notorious float
precision problem. I break the strings with ',', and verify with
String.length() on the second part. I get the precision I need with:
Locale locale = new Locale("pt", "BR");
NumberFormat nf = NumberFormat.getInstance(locale);
nf.setMinimumFractionDigits(7);
Number value = nf.parse(_value);
Doing a println() on 'value' verifies I have the correct format.
Except I now need to write it to a database column formated as Decimal
- I cannot give a string to it. Number.floatValue() rounds my numbers
- I need them in the format I got with println()
Any ideas?
iksrazal