thx,
did you guys worked around it ?
-m
On Nov 30, 2007 7:53 PM, Ryan Lubke <Ryan.Lubke_at_sun.com> wrote:
>
> Matthias Wessendorf wrote:
> > Hi Ryan,
> >
> > I noticed some strange things, when using the NumberConverter for:
> > -currency
> > -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
> > {
> > super.setUp();
> >
> > mock = new NumberConverter();
> > mock.setLocale(Locale.FRANCE);
> > FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
> > }
> >
> > public void testFranceLocale()
> > {
> > UIInput input = new UIInput();
> > mock.setType("currency");
> > Number number = (Number)
> > mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68
> > €");
> > assertNotNull(number);
> > }
> >
> > 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.
> >
> > Why?
> > 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));
> > System.out.println(va1.equals(va2));
> >
> > and you see, what the issue from another side :-)
> >
> > Any ideas?
> > (Or perhaps known bugs?)
> >
> > Thx,
> > Matthias
> >
> >
> Hi Mathias,
>
> This looks pretty similar to http://bugs.sun.com/view_bug.do?bug_id=6318800
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>
>
--
Matthias Wessendorf
further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org