本文整理汇总了Java中javax.money.CurrencyUnit.getCurrencyCode方法的典型用法代码示例。如果您正苦于以下问题:Java CurrencyUnit.getCurrencyCode方法的具体用法?Java CurrencyUnit.getCurrencyCode怎么用?Java CurrencyUnit.getCurrencyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.money.CurrencyUnit
的用法示例。
在下文中一共展示了CurrencyUnit.getCurrencyCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.money.CurrencyUnit; //导入方法依赖的package包/类
public static void main(String[] args) {
CurrencyUnit currencyUnit = Monetary.getCurrency(Locale.US);
String currencyCode = currencyUnit.getCurrencyCode();//USD
int numericCurrencyCode = currencyUnit.getNumericCode();//840
int fractionDigits = currencyUnit.getDefaultFractionDigits();//2
}
示例2: main
import javax.money.CurrencyUnit; //导入方法依赖的package包/类
public static void main(String[] args) {
CurrencyUnit currencyUnit = Monetary.getCurrency("BRL");
String currencyCode = currencyUnit.getCurrencyCode();//BRL
int numericCurrencyCode = currencyUnit.getNumericCode();//2
int fractionDigits = currencyUnit.getDefaultFractionDigits();//986
}
示例3: print
import javax.money.CurrencyUnit; //导入方法依赖的package包/类
@Override
public String print(CurrencyUnit object, Locale locale) {
return object.getCurrencyCode();
}
示例4: getRounding
import javax.money.CurrencyUnit; //导入方法依赖的package包/类
/**
* Access a {@link javax.money.MonetaryRounding} for rounding {@link javax.money.MonetaryAmount}
* instances given a currency.
*
* @param currencyUnit The currency, which determines the required precision. As
* {@link java.math.RoundingMode}, by default, {@link java.math.RoundingMode#HALF_UP}
* is sued.
* @param providers the optional provider list and ordering to be used
* @return a new instance {@link javax.money.MonetaryOperator} implementing the
* rounding, never {@code null}.
* @throws javax.money.MonetaryException if no such rounding could be provided.
*/
public MonetaryRounding getRounding(CurrencyUnit currencyUnit, String... providers) {
MonetaryRounding op =
getRounding(RoundingQueryBuilder.of().setProviderNames(providers).setCurrency(currencyUnit).build());
if(op==null) {
throw new MonetaryException(
"No rounding provided for CurrencyUnit: " + currencyUnit.getCurrencyCode());
}
return op;
}
示例5: getCurrencyName
import javax.money.CurrencyUnit; //导入方法依赖的package包/类
/**
* This method tries to evaluate the localized display name for a
* {@link CurrencyUnit}. It uses {@link Currency#getDisplayName(Locale)} if
* the given currency code maps to a JDK {@link Currency} instance.
* <p>
* If not found {@code currency.getCurrencyCode()} is returned.
*
* @param currency The currency, not {@code null}
* @return the formatted currency name.
*/
private String getCurrencyName(CurrencyUnit currency) {
Currency jdkCurrency = getCurrency(currency.getCurrencyCode());
if (jdkCurrency!=null) {
return jdkCurrency.getDisplayName(locale);
}
return currency.getCurrencyCode();
}
示例6: getCurrencySymbol
import javax.money.CurrencyUnit; //导入方法依赖的package包/类
/**
* This method tries to evaluate the localized symbol name for a
* {@link CurrencyUnit}. It uses {@link Currency#getSymbol(Locale)} if the
* given currency code maps to a JDK {@link Currency} instance.
* <p>
* If not found {@code currency.getCurrencyCode()} is returned.
*
* @param currency The currency, not {@code null}
* @return the formatted currency symbol.
*/
private String getCurrencySymbol(CurrencyUnit currency) {
Currency jdkCurrency = getCurrency(currency.getCurrencyCode());
if (jdkCurrency!=null) {
return jdkCurrency.getSymbol(locale);
}
return currency.getCurrencyCode();
}