commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xavi caballe <xavi.caba...@terra.es>
Subject problem with LocaleBeanUtils.copyProperties()
Date Sun, 12 Jan 2003 17:52:35 GMT
Hello,
I have a problem with the locale-dependent version of BeanUtils.

I have 2 beans, OrigBean and DestBean.
OrigBean has a property named price (with corresponding getter and
setter) whose type is String.
DestBean has a property named price (with corresponding getter and
setter) whose type is Double.

Then I have the following code:

OrigBean orig = new OrigBean();
// "," IS THE DECIMAL SYMBOL IN SPANISH (my locale)
orig.setPrice("123,54");
DestBean dest = new DestBean();
try {
   LocaleBeanUtils.copyProperties(dest, orig);
}
catch (Exception e) {
   System.out.println(e.getMessage());   
}
System.out.println("dest.price:" + dest.getPrice());
System.out.println(java.util.Locale.getDefault());
java.text.NumberFormat df = java.text.DecimalFormat.getInstance();
System.out.println(((java.text.DecimalFormat)df).getDecimalFormatSymbols().getDecimalSeparator());

and I get the following output:

dest.price:0.0
es_ES
,


Why? I should get "123.54", shouldn't I?

Am I doing something wrong?

I would appreciate your help. Thanks in advance.

Xavi

Mime
View raw message