当前位置: 首页>>代码示例>>Java>>正文


Java CurrencyUnit.getCurrencyCode方法代码示例

本文整理汇总了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

}
 
开发者ID:otaviojava,项目名称:money-api-book-samples,代码行数:8,代码来源:CurrencyExample2.java

示例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

    }
 
开发者ID:otaviojava,项目名称:money-api-book-samples,代码行数:9,代码来源:CurrencyExample1.java

示例3: print

import javax.money.CurrencyUnit; //导入方法依赖的package包/类
@Override
public String print(CurrencyUnit object, Locale locale) {
	return object.getCurrencyCode();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:CurrencyUnitFormatter.java

示例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;
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:22,代码来源:BaseMonetaryRoundingsSingletonSpi.java

示例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();
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:18,代码来源:CurrencyToken.java

示例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();
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:18,代码来源:CurrencyToken.java


注:本文中的javax.money.CurrencyUnit.getCurrencyCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。