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