Hi Sven,

I did not got time to create the JIRA...
About the link you mention, I think it is a little bit old because, as far
I remember from my test, the following code is (now) working

String value = "12 345,68 €";
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.FRANCE);
ParsePosition pp = new ParsePosition(0);
Number n = (Number) nf.parse(value, pp);
System.out.println(n);

Please note that there is still a bug in java where Locale.FRANCE is not
the same as new Locale("fr", "FR") for instance but that's another topic.
I can confirm that the following workaround code is also working (which is
equivalent to the code above)

locale = Locale.FRANCE;
final NumberFormat format = this.getNumberFormat(locale);
return this.parse(format, value, locale);

Thanks & best regards,
Sebastien.


On Thu, Jan 17, 2013 at 5:22 PM, Sven Meier <s...@meiers.net> wrote:

> It seems currency formatting is broken in Java:
>
> http://matthiaswessendorf.**wordpress.com/2007/12/03/**
> javas-numberformat-bug/<http://matthiaswessendorf.wordpress.com/2007/12/03/javas-numberformat-bug/>
>    
> http://bugs.sun.com/view_bug.**do?bug_id=4510618<http://bugs.sun.com/view_bug.do?bug_id=4510618>
>
> Regards
> Sven
>
>
> On 01/17/2013 03:42 PM, Sven Meier wrote:
>
>> The problem is the space before the currency sign. It should not be
>> converted to non-break-space.
>>
>> Please open a new issue.
>>
>> Sven
>>
>> On 01/17/2013 11:59 AM, Sebastien wrote:
>>
>>> Oops, sent to dev@ instead of users@, sorry.
>>>
>>> On Thu, Jan 17, 2013 at 11:50 AM, Sebastien <seb...@gmail.com> 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.
>>>>
>>>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org<users-unsubscr...@wicket.apache.org>
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to