tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: how to configure tomcat for Turkey?
Date Fri, 05 Jan 2007 15:04:24 GMT
Hash: SHA1

To whom it may concern,

Dharma General wrote:
> would u plz tell me how can i configure tomcat to turkey locale?

Tomcat should default to the locale of the JVM, so you should switch the
locale of your JVM in order to get Tomcat into Turkey's locale.

> fyi, my tomcat apache 5.x is presently configured for
> US English locale.

Run the following program and check the values for "user.language" and
"". If they don't match what you expect, then your JVM is
not yet configured properly.

public class Env
    public static void main(String[] args)

Now, on to the /real/ problem. What you have done is use
Float.parseFloat() in order to read-in a floating-point number. This is
never ever going to work for you, assuming that Turkey doesn't follow
the English convention of using a dot ('.') as the decimal separator.

The problem is that Float.parseFloat is written to read only
English-formatted floating point numbers. It will always fail to read
"0,00" as a floating-point value, regardless of your JVM (or Tomcat)
settings. It will always fail.

Instead of Float.parseFloat, you need to use the localizable tools found
in the java.text package. The most important one for you is the
DecimalFormat class (although I'll be using the NumberFormat class
instead for convenience). Here's a quick idea for how to use it.

You used to have this:

float f = Float.parseFloat("0,00");

You need to change it to this:

import java.text.NumberFormat;
NumberFormat nf = NumberFormat.getNumberInstance(yourLocale);
float f = nf.parse("0,00").floatValue();

This ought to work for you. Note that 0,00 isn't the best test value ;)

This article might help you once you get more into using the
NumberFormat class:

Good luck,
- -chris

Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla -


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message