• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with DecimalFormat Locale in Linux

 
Estela Tonzan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

we have problems when using a DecimalFormat with our LOCALE ("ES").

As an example we have got the next servlet

import java.io.*;
import java.text.*;
import java.util.*;
import javax.naming.InitialContext;
import javax.servlet.*;
import javax.servlet.http.*;



public class HelloWorldExample extends HttpServlet {
private String greeting;

public void init()
throws ServletException
{
greeting = getInitParameter("greeting");
}

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out = response.getWriter();

///
Locale locale = Locale.getDefault();
System.out.println(locale.toString());

DecimalFormat format=(DecimalFormat) java.text.NumberFormat.getInstance(new Locale("es","ES"));
Integer minumeri=new Integer(1234567);
System.out.println(format.format(minumeri));
///
out.println("Hello, world!:"+format.format(minumeri));
out.close();

}

public void destroy()
{
// nothing to do
}
}



When running this in in Windows TOMCAT 5.5 JRE 1.5 we get the proper expected result 1.234.567 (. is the usual thousands separator in Spain).

The specifications of our server are:

Red Hat Enterprise Linux Server release 5.2
kernel 2.6.18-92.1.18
java-1.6.0-sun-1.6.0.5
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)
tomcat5-5.5.23

When deployed, that very same servlet got as output 1234567. Which is NOT what we want at all.

At this point we are kind of stalled.
We have tried different things and none of them turned out well!
The only solution we can think of is changing the code of all our servlets (thousands of lines there!!!) so that the numbers format is the one we need.
Hopefully someone will help us with a much more efficient, smart and easy solution.
Thanks in advance!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic