[kaffe] Currency and SimpleDateFormat

Ito Kazumitsu ito.kazumitsu at hidec.co.jp
Sun Jan 23 22:38:26 PST 2005


In message "[kaffe] Currency, timezone, etc."
    on 05/01/23, Ito Kazumitsu <kaz at maczuka.gcd.org> writes:

> Caused by: java.lang.IllegalArgumentException: Invalid (empty) country code for 
> locale:en
>    at java.util.Currency.<init> (Currency.java:187)
>    at java.util.Currency.getInstance (Currency.java:280)
>    at java.text.DecimalFormatSymbols.<init> (DecimalFormatSymbols.java:151)
>    at java.text.NumberFormat.computeInstance (NumberFormat.java:327)
>    at java.text.NumberFormat.getNumberInstance (NumberFormat.java:456)
>    at java.text.NumberFormat.getInstance (NumberFormat.java:381)
>    at java.text.SimpleDateFormat.<init> (SimpleDateFormat.java:220)

I do not see why java.util.Currency is needed while
initializing a java.text.SimpleDateFormat.

Running the attached test program with both kaffe and Sun's JDK,
you will find that Currency.getInstance(Locale.ENGLISH)
fails with both kaffe and Sun's,  so it is OK.

But new SimpleDateFormat("EEEE", Locale.ENGLISH) fails with
kaffe because of Currency.getInstance(Locale.ENGLISH), which
is not the case with Sun's JDK.

import java.util.Currency;
import java.util.Locale;
import java.text.SimpleDateFormat;

public class TestCurrency {
  public static void main(String[] args) {
    try {
        Currency.getInstance(Locale.ENGLISH);
    }
    catch (Exception e) {
        System.err.println("Currency.getInstance: " + e);
    }
    try {
        new SimpleDateFormat("EEEE", Locale.ENGLISH);
    }
    catch (Exception e) {
        System.err.println("new SimpleDateFormat: " + e);
    }
  }
}




More information about the kaffe mailing list