commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: problem with LocaleBeanUtils.copyProperties()
Date Mon, 13 Jan 2003 19:14:04 GMT
hi

i'm afraid that i've got some bad news. LocaleBeanUtils.copyProperties 
does not (at the moment) support locale-aware conversions. i looked into 
the work that would be required but it's quite large.

the next beanutils release is coming very soon now and i don't think that 
this will get done before then. i've added this as a bug to bugzilla (http:
//nagoya.apache.org/bugzilla/show_bug.cgi?id=16038) so if you want to keep 
track of progress you can add yourself as a CC.

if you're only using your default locale then maybe registering 
DoubleLocaleConverter with ConvertUtils as the Double converter (before 
calling copyProperties) might work.

- robert

On Sunday, January 12, 2003, at 05:52 PM, xavi caballe wrote:

> 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
>
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-user-help@jakarta.apache.
> org>
>


Mime
View raw message