?
Solved

convert Currency back to double

Posted on 2006-10-24
2
Medium Priority
?
1,215 Views
Last Modified: 2008-02-01
If i've used the following code to convert a double into formatted currency is there any way to convert back?

for instance:

NumberFormat FormatCurrency = NumberFormat.getCurrencyInstance();
String sBalance = FormatCurrency.format(5100.25);

now that sBalance = $5,100.25 how could I convert this back to 5100.25 as a double?

Thanks
0
Comment
Question by:mgcIT
2 Comments
 
LVL 9

Accepted Solution

by:
shinobun earned 2000 total points
ID: 17798889
Use the parse method [1].

Number number = FormatCurrency.parse(sBalance);
double asDouble = number.doubleValue();

http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html#parse(java.lang.String)
0
 
LVL 18

Author Comment

by:mgcIT
ID: 17799652
perfect... thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question