convert a string to double with precision
I am getting a value amount of say $45.00 from a jsp and set this value as a string for my other work. then i am changing this string to double by using this statement
setAmount(Double.parseDouble(cstmt.getString(1)));
my precision is lost when i get this amount it just shows 45.0 how can I get the precision of 45.00
I would appreciate if any assistance is provided for the problem.
thanks
[425 byte] By [
SubhaMania] at [2007-11-27 9:48:10]

I get the feeling that you are confusing precision with display of numbers. They have little to do with each other. You'd best read up on double, precision, and display of numeric data in Java (check out String.Format). You need to adjust your thinking here.
JSP's can use NumberFormat.
However you should never use float/double to represent monetary values. Money has an absolute value (in terms of units used to purchase). Float and double do not (actually they do but they are in base 2 NOT base 10 like most money is). In most cases representation errors due to float and double do not really matter (if you have suitably analysed the usage of them) however people get very upset about errors when it comes to money
matfud.