本文整理匯總了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);
}