It is for dev@ :-) I don't have much experience with Java text converters, so I'll let someone else to comment.
On Thu, Jan 17, 2013 at 12:59 PM, Sebastien <[email protected]> wrote: > Oops, sent to dev@ instead of users@, sorry. > > On Thu, Jan 17, 2013 at 11:50 AM, Sebastien <[email protected]> wrote: > > > Dear all, > > > > There is an issue when using AbstractNumberConverter when > #getNumberFormat > > returns NumberFormat#getCurrencyInstance() > > I think the problem is due to AbstractNumberConverter#parse(Object, > > double, double, Locale): > > > > if (value instanceof String) > > { > > // Convert spaces to no-break space (U+00A0) to fix problems with > > // browser conversions. > > // Space is not valid thousands-separator, but no-br space is. > > value = ((String)value).replace(' ', '\u00A0'); > > } > > > > Which replace spaces, so a string like "1,5 €" is invalid while being > > parsed. > > The workaround is not huge, but I want to ensure if it's by design or if > I > > should open a JIRA. > > > > public class CurrencyConverter extends AbstractNumberConverter<Double> > > { > > private static final long serialVersionUID = 1L; > > > > public CurrencyConverter(IJQueryCultureWidget widget) > > { > > } > > > > @Override > > protected Class<Double> getTargetType() > > { > > return Double.class; > > } > > > > @Override > > public NumberFormat getNumberFormat(Locale locale) > > { > > return NumberFormat.getCurrencyInstance(locale); > > } > > > > @Override > > public Double convertToObject(String value, Locale locale) > > { > > locale = Locale.FRANCE; > > > > return this.parse(value, Double.MIN_VALUE, Double.MAX_VALUE, > > locale); > > > > // This does work: > > // final NumberFormat format = this.getNumberFormat(locale); > > // return this.parse(format, value, locale); > > } > > } > > > > Thanks & best regards, > > Sebastien. > > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com <http://jweekend.com/>
