struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rod McChesney <rod.mcches...@openwave.com>
Subject Re: [validator] numbers with localized decimal separator
Date Wed, 15 Jan 2003 20:32:11 GMT
This is deeper in the validation code, but I believe that
java.text.DecimalFormat should be used for float
or double parsing. Using Double d = new Double(string)
the way GenericTypeValidator does will not work right in other locales.

The javadoc for class Double says this in the secion on the
valueOf(String s) method:

   To interpret localized string representations of a
   floating-point value, use subclasses of NumberFormat.

HTH,

Rod

Gemes Tibor wrote:
> 2003. január 15. 10:42 dátummal Simon Kelly ezt írtad:
> 
> 
>>Btw are you aware of any other Locale in which the decimal separator is not
>>'.'?
>>
>>Germany uses the ',' as well.
> 
> 
> ok, so I assume this is a problem. 
> 
> Do you think that is there any other way of validating float number input but 
> masking it with the pattern  ^\d*(,\d*)?$  where the ',' should be replaced 
> with the localized decimal separator?
> 
> Tib
> 
> Oh, and this should parsed localized as well, and replaced each parseFloat 
> with this imho.
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message