GlobalizationPreferences gp = new GlobalizationPreferences();
// Set language only locale - ja
logln("Set locale - ja");
gp.setLocale(new ULocale("ja"));
Currency cur = gp.getCurrency();
String code = cur.getCurrencyCode();
if (!code.equals("JPY")) {
errln("FAIL: Currency is " + code + " - Expected: JPY");
}
gp.reset();
// Set locales with territory
logln("Set locale - ja_US");
gp.setLocale(new ULocale("ja_US"));
cur = gp.getCurrency();
code = cur.getCurrencyCode();
if (!code.equals("USD")) {
errln("FAIL: Currency is " + code + " - Expected: USD");
}
// Set locales with territory in the second locale
logln("Set locales - it, en_US");
ULocale[] locales = new ULocale[2];
locales[0] = new ULocale("it");
locales[1] = new ULocale("en_US");
gp.setLocales(locales);
cur = gp.getCurrency();
code = cur.getCurrencyCode();
if (!code.equals("USD")) {
errln("FAIL: Currency is " + code + " - Expected: USD");
}
// Set explicit territory
logln("Set territory - DE");
gp.setTerritory("DE");
cur = gp.getCurrency();
code = cur.getCurrencyCode();
if (!code.equals("EUR")) {
errln("FAIL: Currency is " + code + " - Expected: EUR");
}
// Set explicit currency
Currency ecur = Currency.getInstance("BRL");
gp.setCurrency(ecur);
logln("Set explicit currency - BRL");
cur = gp.getCurrency();
code = cur.getCurrencyCode();
if (!code.equals("BRL")) {
errln("FAIL: Currency is " + code + " - Expected: BRL");
}
// Set explicit territory again
logln("Set territory - JP");
cur = gp.getCurrency();
code = cur.getCurrencyCode();
if (!code.equals("BRL")) {
errln("FAIL: Currency is " + code + " - Expected: BRL");
}
// Freeze
logln("Freeze this object");
Currency ecur2 = Currency.getInstance("CHF");
boolean bFrozen = false;
gp.freeze();
try {
gp.setCurrency(ecur2);
} catch (UnsupportedOperationException uoe) {