----- Original Message ----- From: "Jan Luehe" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, April 27, 2002 4:25 PM Subject: Re: Confused about <fmt:formatNumber> and the currencyCode attribute
>Martin: > >> According to the PFD, if I'm running on J2SE 1.4 and I use a tag like this: >> >> <fmt:formatNumber value="12.34" type="currency" currencyCode="GBP" /> >> >> I should see, I believe "(pound sign)12.34" in my browser. However, what I'm >> seeing is "GBP12.34" instead. > >Hmm, I get the expected: > > £12.34 > >Did you remember to set your browser's preferred locale to "en-GB", >or use <fmt:setLocale> with that locale? I didn't have a problem when I used <fmt:setLocale>, but I was experimenting with how <fmt:formatNumber> behaves without using that. It turns out that what I was doing wrong was setting my system's locale to "English (United Kingdom)" but forgetting to set the browser itself to the same locale. Doh! Sorry... >I get "GBP12.34" only when running on J2SE 1.3, or when running on >J2SE 1.4 with a preferred locale other than "en-GB". > >> This appears to be the case for any currency code I use except USD, when I >> see $12.34, as I would expect. (I discovered, though, that if I use J2SE 1.3 >> instead, I get "USD12.34", so there's definitely some progress in moving to >> 1.4. :) >> >> I tried specifying the numeric currency code instead, and the result was an >> exception, although the PFD doesn't state that only the character values for >> currency code are supported. >> >> What am I doing wrong? > >What exactly is the exception you are getting? I'm getting a JspTagException from line 212 of FormatNumberSupport.java. There is no root cause reported, so I can't be more specific. >The tag handler calls java.util.Currency.getInstance() with the >specified currency code. This method throws an >IllegalArgumentException "if <code>currencyCode</code> is not a >supported ISO 4217 code" (quoted from the javadocs). This is what we >mention in the "Constraints" section of <fmt:formatNumber>. We do >not implement any additional constraints on the currency code. ISO 4217 defines both alphabetic and numeric currency codes. There is nothing in the javadoc for java.util.Currency, or elsewhere as far as I can determine, to indicate that only the alphabetic form is supported. However, perhaps this is the case, and that's why I'm getting an exception when I try to use the numeric form? -- Martin Cooper > > > >Jan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>