Solved

convert Currency back to double

Posted on 2006-10-24
2
1,203 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 62
reverse digits of a number using for loop 5 52
java jdbc batch example 8 41
SHA2 certs for IIS AND Java? 2 113
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

808 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