Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

converting String to double

807569Aug 24 2006 — edited Aug 25 2006
Hi.

In my JSP I easily converted a double I made to a string value, to show percent on a page.

I'm trying to pass it back to my servlet, the string value, that is, which it does just fine.

Now I'm trying to recast that String value back to that of a double, but am getting the error:
java.lang.NumberFormatException: 18.182%
Not sure why.

Can anyone please look at this and let me know what's wrong?
My servlet compiles just fine, and if I put in a try catch block to catch an NFE exception being thrown, it of course just bypasses it altogether.
String appercent$ = request.getParameter("appercent$");
NumberFormat percent = NumberFormat.getPercentInstance();
percent.setMinimumFractionDigits(3);
double apprecentdbl = Double.parseDouble(appercent$);
Thanks!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2006
Added on Aug 24 2006
5 comments
356 views