You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dharma General <dh...@gmail.com> on 2007/01/04 21:37:44 UTC

how to configure tomcat for Turkey?

hello,

(1) i want my JSP application to run with Turkey locale. how should i
configure apache Tomcat 5.x for Turkey?
(2) at present, i want to find out about an error message ---

java.lang.NumberFormatException: For input string: "0,00"
    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
    at java.lang.Float.parseFloat(Unknown Source)

what is it?

thx

Re: how to configure tomcat for Turkey?

Posted by David Smith <dn...@cornell.edu>.
Dharma General wrote:

> (2) at present, i want to find out about an error message ---
>
> java.lang.NumberFormatException: For input string: "0,00"
>    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
>    at java.lang.Float.parseFloat(Unknown Source)
>
> what is it?
>
> thx
>
Read the java api docs for java.lang.NumberFormatException and
java.lang.Float.  Specifically the following link should shed some light
on the exception:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Float.html#valueOf(java.lang.String)

There's also a link there to java.text.NumberFormat which should provide
some methods for localized parsing of values.

--David

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


Re: how to configure tomcat for Turkey?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----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


Re: how to configure tomcat for Turkey?

Posted by Dharma General <dh...@gmail.com>.
gents,

thanks for your response.

would u plz tell me how can i configure tomcat to turkey locale? what
changes are required? fyi, my tomcat apache 5.x is presently configured for
US English locale.

thx again.

On 1/4/07, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
>
> it's your "," character.
> you need to use the java.text.DecimalFormat class
>
> Filip
>
> Dharma General wrote:
> > hello,
> >
> > (1) i want my JSP application to run with Turkey locale. how should i
> > configure apache Tomcat 5.x for Turkey?
> > (2) at present, i want to find out about an error message ---
> >
> > java.lang.NumberFormatException: For input string: "0,00"
> >    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
> >    at java.lang.Float.parseFloat(Unknown Source)
> >
> > what is it?
> >
> > thx
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.432 / Virus Database: 268.16.4/615 - Release Date: 1/3/2007
> 1:34 PM
> >
>
>
> ---------------------------------------------------------------------
> 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
>
>

Re: how to configure tomcat for Turkey?

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
what I am saying is that I don't believe java.lang.Float.parseFloat 
parses according to the local, it always uses "." and not ","
so changing your locale will most likely not affect the Float.parseFloat 
operation.

hence you should use the java.text.DecimalFormat

Filip

Dharma General wrote:
> filip, thanks. but turkey locale uses "," to denote decimal vs "." in 
> USA.
> for further testing, plz tell me what changes i need to make to tomcat to
> use turkey locale so that i can test my app in usa?
>
> On 1/4/07, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
>>
>> it's your "," character.
>> you need to use the java.text.DecimalFormat class
>>
>> Filip
>>
>> Dharma General wrote:
>> > hello,
>> >
>> > (1) i want my JSP application to run with Turkey locale. how should i
>> > configure apache Tomcat 5.x for Turkey?
>> > (2) at present, i want to find out about an error message ---
>> >
>> > java.lang.NumberFormatException: For input string: "0,00"
>> >    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
>> >    at java.lang.Float.parseFloat(Unknown Source)
>> >
>> > what is it?
>> >
>> > thx
>> >
>> > 
>> ------------------------------------------------------------------------
>> >
>> > No virus found in this incoming message.
>> > Checked by AVG Free Edition.
>> > Version: 7.5.432 / Virus Database: 268.16.4/615 - Release Date: 
>> 1/3/2007
>> 1:34 PM
>> >
>>
>>
>> ---------------------------------------------------------------------
>> 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
>>
>>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.16.5/616 - Release Date: 1/4/2007 1:34 PM
>   


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


Re: how to configure tomcat for Turkey?

Posted by Dharma General <dh...@gmail.com>.
filip, thanks. but turkey locale uses "," to denote decimal vs "." in USA.
for further testing, plz tell me what changes i need to make to tomcat to
use turkey locale so that i can test my app in usa?

On 1/4/07, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
>
> it's your "," character.
> you need to use the java.text.DecimalFormat class
>
> Filip
>
> Dharma General wrote:
> > hello,
> >
> > (1) i want my JSP application to run with Turkey locale. how should i
> > configure apache Tomcat 5.x for Turkey?
> > (2) at present, i want to find out about an error message ---
> >
> > java.lang.NumberFormatException: For input string: "0,00"
> >    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
> >    at java.lang.Float.parseFloat(Unknown Source)
> >
> > what is it?
> >
> > thx
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.432 / Virus Database: 268.16.4/615 - Release Date: 1/3/2007
> 1:34 PM
> >
>
>
> ---------------------------------------------------------------------
> 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
>
>

Re: how to configure tomcat for Turkey?

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
it's your "," character.
you need to use the java.text.DecimalFormat class

Filip

Dharma General wrote:
> hello,
>
> (1) i want my JSP application to run with Turkey locale. how should i
> configure apache Tomcat 5.x for Turkey?
> (2) at present, i want to find out about an error message ---
>
> java.lang.NumberFormatException: For input string: "0,00"
>    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
>    at java.lang.Float.parseFloat(Unknown Source)
>
> what is it?
>
> thx
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.16.4/615 - Release Date: 1/3/2007 1:34 PM
>   


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