Locale spanish = new Locale("es", "ES");
Locale german = new Locale("de", "DE");
// Thousands and decimal separators are different in Spain
Format numFormat = new Format("#,000.00", spanish);
assertEquals("123.456,79", numFormat.format(new Double(123456.789)));
// Currency too
Format currencyFormat = new Format("Currency", spanish);
assertEquals(
"1.234.567,79 " + Euro,
currencyFormat.format(new Double(1234567.789)));
// Dates
Format dateFormat = new Format("Medium Date", spanish);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2005);
calendar.set(Calendar.MONTH, 0); // January, 0-based
calendar.set(Calendar.DATE, 22);
java.util.Date date = calendar.getTime();
assertEquals("22-ene-05", dateFormat.format(date));
// Dates in German
dateFormat = new Format("Long Date", german);
assertEquals("Samstag, Januar 22, 2005", dateFormat.format(date));
}