Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with DecimalFormat Locale in Linux  RSS feed

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.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();

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


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 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)

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!
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!