本文整理汇总了Java中java.util.Currency.getSymbol方法的典型用法代码示例。如果您正苦于以下问题:Java Currency.getSymbol方法的具体用法?Java Currency.getSymbol怎么用?Java Currency.getSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Currency
的用法示例。
在下文中一共展示了Currency.getSymbol方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatPrice
import java.util.Currency; //导入方法依赖的package包/类
public static String formatPrice(double price, String currency) {
String s = null;
try{
Currency c = Currency.getInstance(currency);
s = c.getSymbol(Locale.getDefault());
}catch (Exception ex){
s = currency;
}
return s+" "+priceFormatter.format(price);
}
示例2: getCurrencySymbol
import java.util.Currency; //导入方法依赖的package包/类
private static String getCurrencySymbol(final String currencyCode) {
Currency currency = null;
try {
currency = Currency.getInstance(currencyCode);
} catch (IllegalArgumentException e) {
// Unknown currency code, ignore.
}
return currency != null ? currency.getSymbol() : currencyCode;
}
示例3: ProductAdapter
import java.util.Currency; //导入方法依赖的package包/类
public ProductAdapter(Context context, OnproductClickListener onproductClickListener) {
this.context = context;
this.productList = new ArrayList<>();
this.onproductClickListener = onproductClickListener;
formatprice = new DecimalFormat("#0,000");
sharedPref = context.getSharedPreferences(ViMarket.TABLE_USER, Context.MODE_PRIVATE);
imageWidth = sharedPref.getInt(ViMarket.THUMBNAIL_SIZE,
0); // Load image width for grid view
Locale current = new Locale("vi","VN");
Currency cur = Currency.getInstance(current);
format = cur.getSymbol();
}
示例4: MoneyUnit
import java.util.Currency; //导入方法依赖的package包/类
public MoneyUnit(Currency currency, CurrencyConversionProvider currencyConversionProvider) {
super(100,
currency.getSymbol(),
currency.getDisplayName(),
currency.getDisplayName(),
ignored -> { throw new InvalidCurrencyException("Cannot convert currencies"); },
ignored -> { throw new InvalidCurrencyException("Cannot convert currencies"); });
this.currency = currency;
this.unitCounter = new UnitCounter(this);
this.currencyConversionProvider = currencyConversionProvider;
}
示例5: currencySymbol
import java.util.Currency; //导入方法依赖的package包/类
public static String currencySymbol(final String currencyCode) {
try {
final Currency currency = Currency.getInstance(currencyCode);
return currency.getSymbol();
} catch (final IllegalArgumentException x) {
return currencyCode;
}
}
示例6: getCurrencySymbolFromProperties
import java.util.Currency; //导入方法依赖的package包/类
private static String getCurrencySymbolFromProperties(Currency currency) {
if (properties.containsKey(currency.getCurrencyCode()))
return properties.getProperty(currency.getCurrencyCode()).split(DELIMETER)[CODE];
return currency.getSymbol();
}
示例7: setCurrency
import java.util.Currency; //导入方法依赖的package包/类
private void setCurrency()
{
Currency currency = Currency.getInstance(Locale.getDefault());
String currencySymbol = currency.getSymbol();
setText(currencySymbol);
}
示例8: 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);
}
示例9: 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);
}
示例10: getExchangeRate
import java.util.Currency; //导入方法依赖的package包/类
/**
* The current price of the variable currency when it is exchanged for 1 unit of the fixed currency.
*
* @param fixed
* The currency that is measured in 1 unit.
* @param variable
* The currency thats worth equal to 1 unit of the <code>fixed</code> should be calculated.
* @return The current exchange rate or an empty {@link Optional} if no exchange rate is known.
*/
public Optional<AccuratePrice> getExchangeRate(final Currency fixed, final Currency variable) {
final String forexSymbol = fixed.getSymbol() + variable.getSymbol();
return Optional.ofNullable(store.get(forexSymbol));
}