本文整理汇总了Java中java.util.Currency.getCurrencyCode方法的典型用法代码示例。如果您正苦于以下问题:Java Currency.getCurrencyCode方法的具体用法?Java Currency.getCurrencyCode怎么用?Java Currency.getCurrencyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Currency
的用法示例。
在下文中一共展示了Currency.getCurrencyCode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrice
import java.util.Currency; //导入方法依赖的package包/类
public static String getPrice(Currency currency, double value) {
checkPropertiesAreLoaded();
if (properties.containsKey(currency.getCurrencyCode())) {
String[] currencyStrings = properties.getProperty(currency.getCurrencyCode()).split(DELIMETER);
return getPriceFormatted(value,
1,
currencyBefore.contains(currency.getCurrencyCode()),
Integer.valueOf(currencyStrings[FRACTIONS_NORMAL]),
currencyStrings[CODE]);
} else {
return "not supported currency " + currency.getCurrencyCode();
}
}
示例2: getPricePerLitre
import java.util.Currency; //导入方法依赖的package包/类
public static String getPricePerLitre(Currency currency, double value) {
checkPropertiesAreLoaded();
if (properties.containsKey(currency.getCurrencyCode())) {
String[] currencyStrings = properties.getProperty(currency.getCurrencyCode()).split(DELIMETER);
int coefficientMultiply = Integer.valueOf(currencyStrings[COEFFICIENT_PER_LITRE_MULTIPLY]);
return getPriceFormatted(value,
coefficientMultiply,
currencyBefore.contains(currency.getCurrencyCode()),
Integer.valueOf(currencyStrings[FRACTIONS_PER_LITRE]),
currencyStrings[coefficientMultiply == 1 ? CODE : CODE_PER_LITRE]);
} else {
return "not supported currency " + currency.getCurrencyCode();
}
}
示例3: unwrap
import java.util.Currency; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(Currency value, Class<X> type, WrapperOptions options) {
if ( value == null ) {
return null;
}
if ( String.class.isAssignableFrom( type ) ) {
return (X) value.getCurrencyCode();
}
throw unknownUnwrap( type );
}
示例4: checkCountryCurrency
import java.util.Currency; //导入方法依赖的package包/类
static void checkCountryCurrency(String countryCode, String expected) {
Locale locale = new Locale("", countryCode);
Currency currency = Currency.getInstance(locale);
String code = (currency != null) ? currency.getCurrencyCode() : null;
if (!(expected == null ? code == null : expected.equals(code))) {
throw new RuntimeException("Wrong currency for " +
locale.getDisplayCountry() +
": expected " + expected + ", got " + code);
}
}
示例5: testCountryCurrency
import java.util.Currency; //导入方法依赖的package包/类
private static void testCountryCurrency(String country, String currencyCode,
int digits) {
testCurrencyDefined(currencyCode, digits);
Currency currency = Currency.getInstance(new Locale("", country));
if (!currency.getCurrencyCode().equals(currencyCode)) {
throw new RuntimeException("[" + country
+ "] expected: " + currencyCode
+ "; got: " + currency.getCurrencyCode());
}
}
示例6: setCurrency
import java.util.Currency; //导入方法依赖的package包/类
public void setCurrency(Currency currency) {
this.currencyISOCode = currency.getCurrencyCode();
}
示例7: setCurrency
import java.util.Currency; //导入方法依赖的package包/类
public void setCurrency(Currency currency) {
this.currency = currency.getCurrencyCode();
}
示例8: getAsText
import java.util.Currency; //导入方法依赖的package包/类
@Override
public String getAsText() {
Currency value = (Currency) getValue();
return (value != null ? value.getCurrencyCode() : "");
}
示例9: toString
import java.util.Currency; //导入方法依赖的package包/类
@Override
public String toString(Currency value) {
return value.getCurrencyCode();
}
示例10: serialize
import java.util.Currency; //导入方法依赖的package包/类
@Override
public JsonElement serialize(Currency currency, Type type, JsonSerializationContext context) {
return currency == null ? JsonNull.INSTANCE : new JsonPrimitive(currency.getCurrencyCode());
}
示例11: setCurrency
import java.util.Currency; //导入方法依赖的package包/类
/**
* Sets the currency of these DecimalFormatSymbols.
* This also sets the currency symbol attribute to the currency's symbol
* in the DecimalFormatSymbols' locale, and the international currency
* symbol attribute to the currency's ISO 4217 currency code.
*
* @param currency the new currency to be used
* @exception NullPointerException if <code>currency</code> is null
* @since 1.4
* @see #setCurrencySymbol
* @see #setInternationalCurrencySymbol
*/
public void setCurrency(Currency currency) {
if (currency == null) {
throw new NullPointerException();
}
this.currency = currency;
intlCurrencySymbol = currency.getCurrencyCode();
currencySymbol = currency.getSymbol(locale);
}
示例12: setCurrency
import java.util.Currency; //导入方法依赖的package包/类
/**
* Sets the currency of these DecimalFormatSymbols.
* This also sets the currency symbol attribute to the currency's symbol
* in the DecimalFormatSymbols' locale, and the international currency
* symbol attribute to the currency's ISO 4217 currency code.
*
* @param currency the new currency to be used
* @exception NullPointerException if <code>currency</code> is null
* @since 1.4
* @see #setCurrencySymbol
* @see #setInternationalCurrencySymbol
*/
public void setCurrency(Currency currency) {
if (currency == null) {
throw new NullPointerException();
}
initializeCurrency(locale);
this.currency = currency;
intlCurrencySymbol = currency.getCurrencyCode();
currencySymbol = currency.getSymbol(locale);
}