String tripleCurrencyStr = "\u00A4\u00A4\u00A4";
for (int i=0; i<DATA.length; ++i) {
String locale = DATA[i][0];
String pat = DATA[i][1];
Double numberToBeFormat = new Double(DATA[i][2]);
DecimalFormatSymbols sym = new DecimalFormatSymbols(new ULocale(locale));
for (int j=1; j<=3; ++j) {
// j represents the number of currency sign in the pattern.
if (j == 2) {
pat = Utility.replaceAll(pat, "\u00A4", doubleCurrencyStr);
} else if (j == 3) {
pat = Utility.replaceAll(pat, "\u00A4\u00A4", tripleCurrencyStr);
}
DecimalFormat fmt = new DecimalFormat(pat, sym);
String s = ((NumberFormat) fmt).format(numberToBeFormat);
// DATA[i][3] is the currency format result using a
// single currency sign.
// DATA[i][4] is the currency format result using
// double currency sign.
// DATA[i][5] is the currency format result using
// triple currency sign.
// DATA[i][j+2] is the currency format result using
// 'j' number of currency sign.
String currencyFormatResult = DATA[i][2+j];
if (!s.equals(currencyFormatResult)) {
errln("FAIL format: Expected " + currencyFormatResult);
}
try {
// mix style parsing
for (int k=3; k<=5; ++k) {
// DATA[i][3] is the currency format result using a
// single currency sign.
// DATA[i][4] is the currency format result using
// double currency sign.
// DATA[i][5] is the currency format result using
// triple currency sign.
String oneCurrencyFormat = DATA[i][k];
if (fmt.parse(oneCurrencyFormat).doubleValue() !=
numberToBeFormat.doubleValue()) {
errln("FAILED parse " + oneCurrencyFormat);
}
}
} catch (ParseException e) {
errln("FAILED, DecimalFormat parse currency: " + e.toString());