本文整理汇总了Java中java.util.Locale.ITALY属性的典型用法代码示例。如果您正苦于以下问题:Java Locale.ITALY属性的具体用法?Java Locale.ITALY怎么用?Java Locale.ITALY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.Locale
的用法示例。
在下文中一共展示了Locale.ITALY属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSharedFlyweight
private static boolean isSharedFlyweight(Object obj) {
if (obj == null) {
return true;
}
if (obj == Boolean.TRUE || obj == Boolean.FALSE) {
return true;
}
if (/* obj == Locale.ROOT || *//* Java 6 */
obj == Locale.ENGLISH || obj == Locale.FRENCH || obj == Locale.GERMAN || obj == Locale.ITALIAN
|| obj == Locale.JAPANESE || obj == Locale.KOREAN || obj == Locale.CHINESE
|| obj == Locale.SIMPLIFIED_CHINESE || obj == Locale.TRADITIONAL_CHINESE || obj == Locale.FRANCE
|| obj == Locale.GERMANY || obj == Locale.ITALY || obj == Locale.JAPAN || obj == Locale.KOREA
|| obj == Locale.CHINA || obj == Locale.PRC || obj == Locale.TAIWAN || obj == Locale.UK
|| obj == Locale.US || obj == Locale.CANADA || obj == Locale.CANADA_FRENCH) {
return true;
}
if (obj == Collections.EMPTY_SET || obj == Collections.EMPTY_LIST || obj == Collections.EMPTY_MAP) {
return true;
}
if (obj == BigInteger.ZERO || obj == BigInteger.ONE) {
return true;
}
if (obj == System.in || obj == System.out || obj == System.err) {
return true;
}
if (obj == String.CASE_INSENSITIVE_ORDER) {
return true;
}
if (obj == JarFile.MANIFEST_NAME) {
return true;
}
return false;
}
示例2: testFormatting
static void testFormatting() {
boolean failed = false;
Locale[] locales = {
Locale.US,
Locale.JAPAN,
Locale.GERMANY,
Locale.ITALY,
new Locale("it", "IT", "EURO") };
Currency[] currencies = {
null,
Currency.getInstance("USD"),
Currency.getInstance("JPY"),
Currency.getInstance("DEM"),
Currency.getInstance("EUR"),
};
String[][] expecteds = {
{"$1,234.56", "$1,234.56", "JPY1,235", "DEM1,234.56", "EUR1,234.56"},
{"\uFFE51,235", "USD1,234.56", "\uFFE51,235", "DEM1,234.56", "EUR1,234.56"},
{"1.234,56 \u20AC", "1.234,56 USD", "1.235 JPY", "1.234,56 DM", "1.234,56 \u20AC"},
{"\u20AC 1.234,56", "USD 1.234,56", "JPY 1.235", "DEM 1.234,56", "\u20AC 1.234,56"},
{"\u20AC 1.234,56", "USD 1.234,56", "JPY 1.235", "DEM 1.234,56", "\u20AC 1.234,56"},
};
for (int i = 0; i < locales.length; i++) {
Locale locale = locales[i];
NumberFormat format = NumberFormat.getCurrencyInstance(locale);
for (int j = 0; j < currencies.length; j++) {
Currency currency = currencies[j];
String expected = expecteds[i][j];
if (currency != null) {
format.setCurrency(currency);
int digits = currency.getDefaultFractionDigits();
format.setMinimumFractionDigits(digits);
format.setMaximumFractionDigits(digits);
}
String result = format.format(1234.56);
if (!result.equals(expected)) {
failed = true;
System.out.println("FAIL: Locale " + locale
+ (currency == null ? ", default currency" : (", currency: " + currency))
+ ", expected: " + expected
+ ", actual: " + result);
}
}
}
if (failed) {
throw new RuntimeException();
}
}