NumberConverter using buggy NumberFormat ?

From: Matthias Wessendorf <>
Date: Fri, 30 Nov 2007 19:38:09 +0100

Hi Ryan,

I noticed some strange things, when using the NumberConverter for:
-fr_FR locale

I guess it is a bug in the underlying JDK (1.5.0_11 I am using)........

I did a quick JUnit test-case against the MyFaces API (which contains
the *base* number-converter)

protected void setUp() throws Exception

   mock = new NumberConverter();

public void testFranceLocale()
   UIInput input = new UIInput();
    Number number = (Number)
mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68

And............ it fails :-)

So... what is the work-around?
I assume it is not to not use fr_FR :-))

Also, a simple Java-test fails and shows why:

Doing this:

String va = "12 345,68 ";
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.FRANCE);
Number n = (Number) nf.parseObject(va);

and you'll see that n is NULL.

So, here it is:
the String va contains two blanks (" "), which are between 2 and 3, and
between 8 and as well.

In fr_FR, however, the *grouping separator * is not " ", but it is a
special char for blank (\u00a0).
So, my little test will pass, when the first BLANK is replaced by the
special char...

I thought, that the NumberFormat actually does parse the object for me!!
Looks like for the "fr_FR" locale, I have to create a *custom parser*...
Which is odd, IMO

Now, do this:

String va1 = "12 345,68 ";
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.FRANCE);
String va2 = nf.format(12345.68));

and you see, what the issue from another side :-)

Any ideas?
(Or perhaps known bugs?)


Matthias Wessendorf
further stuff:
mail: matzew-at-apache-dot-org