tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: how to configure tomcat for Turkey?
Date Fri, 05 Jan 2007 15:04:24 GMT
-----BEGIN PGP SIGNED MESSAGE-----
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
"user.country". 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)
    {
        System.getProperties().list(System.out);
    }
}

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:
http://www-128.ibm.com/developerworks/java/library/j-numberformat/index.html

Good luck,
- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFnmj49CaO5/Lv0PARArmUAJ91h+rIV3gUupDosoKg+o40+MPjFACePZu4
qBD6ctxEkg29qlcPDXN6KVc=
=64Xr
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message