The moose likes Beginning Java and the fly likes Number Format problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Number Format problem" Watch "Number Format problem" New topic

Number Format problem

Yaddif Medina

Joined: Oct 05, 2005
Posts: 23
Hi all,

I have a problem with my web application in Linux (White Box 4). The DecimalFormat that I am using does not take into account the "regional setting". The linux have the numeric format as : "12,123,123.45" (which I wanted), but when I executed the following sentence it returns "12.123.123,45" !!!.

java.text.NumberFormat df=java.text.DecimalFormat.getCurrencyInstance(java.util.Locale.US);

How can I force to the right format? it is not supposed to be taken from the operating system?.

PS. If I run my application in a windows server it works fine.

Thanks in advance.

Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
I'm not sure why you're getting the results you're getting. You could try specifically setting the DecimalFormatSymbols to the US Locale.

[ March 18, 2006: Message edited by: Garrett Rowe ]

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Yaddif Medina

Joined: Oct 05, 2005
Posts: 23
The problem is that I am running Jasper Report for my application and it is not formating the number as the "regional setting" ... are there some "global" java parameter to do this?

I agree. Here's the link:
subject: Number Format problem
jQuery in Action, 3rd edition