troubleshooting Question

Reading numbers including commas as thousands separator

Avatar of jespersahner
jespersahner asked on
7 Comments1 Solution2324 ViewsLast Modified:

I am reading some numbers including commas as thousands separator from a text-file, that is numbers on the form -1,234.56

My question now is how I convert a number on this form into a double?

If the number didn't contain commas as thousands separator I could just use Doble.parseDouble(String), and of course I can have comma removed using Double.parseDouble(String.replaceAll(",","")). However I am looking for a more general solution using some kind of formatter. How can I do that?

Mick Barry
Java Developer
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros