| Author |
Number format exception while converting String to double
|
Reshmi Kuttappan
Greenhorn
Joined: May 26, 2009
Posts: 17
|
|
currnecyt = "$0.00";
tempCrntMnthRate += Double.parseDouble(currnecyt);
Am getting a Number format exception as "java.lang.NumberFormatException: For input string: "$0.00""
Please help..........
|
 |
Reshmi Kuttappan
Greenhorn
Joined: May 26, 2009
Posts: 17
|
|
currnecyt = "$0.00";
tempCrntMnthRate += Double.parseDouble(currnecyt);
Am getting a Number format exception as "java.lang.NumberFormatException: For input string: "$0.00""
Please help..........
|
 |
Balu Sadhasivam
Ranch Hand
Joined: Jan 01, 2009
Posts: 874
|
|
From API ,
Throws NumberFormatException - if the string does not contain a parsable double.
$0.00 should be converted to 0.00 before using parseDouble.
|
 |
Reshmi Kuttappan
Greenhorn
Joined: May 26, 2009
Posts: 17
|
|
Balu Sadhasivam wrote:
From API ,
Throws NumberFormatException - if the string does not contain a parsable double.
$0.00 should be converted to 0.00 before using parseDouble.
hey thanks..............I tried it & its working fine........
|
 |
Nitish Bangera
Ranch Hand
Joined: Jul 15, 2009
Posts: 536
|
|
|
Did you understand why you were getting a Numberformatexception? When you do a parseDouble...it takes a string so the compilation is ok. But during runtime when the number is actually converted, it doesn't get converted to a double because the the format of the number you have passed is not a double but rather a String because of the $.
|
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
|
 |
 |
|
|
subject: Number format exception while converting String to double
|
|
|