Hi,
here is a little patch for the org.apache.struts.util.ConvertUtils. It
corrects wrong typed double or float values before converting them. For
many users it is very common to use a "," instead of a ".". At least in
Germany.
We would appreciate if you commit this patch for the next release.
Thanx a lot
Gunnar Eilers
private static Double convertDouble(String value,
Double defaultValue) {
+ // if anybody types ',' instead of '.' for a double or float
value
+ // a very popular mistake in Germany :-)
+ if (value != null)
+ value = value.replace(',', '.');
try {
return (new Double( value ));
} catch (NumberFormatException e) {
return (defaultValue);
}
}
/**
* Convert a String value to a corresponding Float value.
*
* @param value The string value to convert
* @param defaultValue Default value to return on a conversion error
*/
private static Float convertFloat(String value,
Float defaultValue) {
+ // if anybody types ',' instead of '.' for a double or float
value
+ // a very popular mistake in Germany :-)
+ if (value != null)
+ value = value.replace(',', '.');
try {
return (new Float(value));
} catch (NumberFormatException e) {
return (defaultValue);
}
}
--
===============================================================
Slimnet Ern�hrungsberatung & CO.
Obere-Masch-Strasse 20
37073 G�ttingen
Tel: 0551 / 49 99 222
Fax: 0551 / 49 99 229
-----------------------------------------------------------------------------
>>>>> mailto:[EMAIL PROTECTED] <<+>> http://www.slimnet.de <<<<<<
-----------------------------------------------------------------------------