Solved

Java and Currency Counting (Brazil)

Posted on 2011-03-09
4
458 Views
Last Modified: 2012-05-11
Hi Experts,

I'm trying to format currency in Brazil but Java simply does not know how to handle this.

ex:
NumberFormat format = NumberFormat.getInstance(new Locale("br"));
Object value = format.parse("5,45");

value ends up translating to 54500.  It's very strange.  Does anyone know why and how I can properly format the value?

Thanks!
0
Comment
Question by:Greengiants15
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:objects
ID: 35090616
0
 
LVL 92

Expert Comment

by:objects
ID: 35090630
and you should be use getCurrencyInstance() to parse a currency value
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 35093013
You're constructing your Locale wrongly. Should be
new Locale("pt", "BR")

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35095023
:)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now