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


Java DecimalFormatSymbols.setCurrencySymbol方法代码示例

本文整理汇总了Java中java.text.DecimalFormatSymbols.setCurrencySymbol方法的典型用法代码示例。如果您正苦于以下问题:Java DecimalFormatSymbols.setCurrencySymbol方法的具体用法?Java DecimalFormatSymbols.setCurrencySymbol怎么用?Java DecimalFormatSymbols.setCurrencySymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.text.DecimalFormatSymbols的用法示例。


在下文中一共展示了DecimalFormatSymbols.setCurrencySymbol方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _setCurrencyInformation

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
private void _setCurrencyInformation(
  RequestContext context,
  DecimalFormatSymbols symbols)
{
  String currencyCode = _getCurrencyCode(context);

  // currencyCode is set we honour currency code.
  if (currencyCode != null)
  {
    symbols.setCurrency(Currency.getInstance(currencyCode));
    return;
  }

  if (getCurrencySymbol() != null)
  {
    symbols.setCurrencySymbol(getCurrencySymbol());

     // Loggin at level INFO - shows up by default - so use fine.
    _LOG.fine("Using currency symbol as currecny code evaluates to null");
  }
  // currency symbol will now default based on the locale.
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:23,代码来源:NumberConverter.java

示例2: createTestObject

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
private File createTestObject(String objectName, String expString){
    DecimalFormatSymbols dfs= new DecimalFormatSymbols();
    dfs.setExponentSeparator(expString);
    dfs.setCurrencySymbol("*SpecialCurrencySymbol*");
    logln(" The special exponent separator is set : "  + dfs.getExponentSeparator());
    logln(" The special currency symbol is set : "  + dfs.getCurrencySymbol());

    // 6345659: create a test object in the test.class dir where test user has a write permission.
    File file = new File(System.getProperty("test.class", "."), objectName);
    try (FileOutputStream ostream = new FileOutputStream(file)) {
        ObjectOutputStream p = new ObjectOutputStream(ostream);
        p.writeObject(dfs);
        //System.out.println(" The special currency symbol is set : "  + dfs.getCurrencySymbol());
        return file;
    } catch (Exception e){
        errln("Test Malfunction in DFSSerialization: Exception while creating an object");
        /*
         * logically should not throw this exception as errln throws exception
         * if not thrown yet - but in case errln got changed
         */
        throw new RuntimeException("Test Malfunction: re-throwing the exception", e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:DFSSerialization.java

示例3: setSymbolAndCode

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/** Set the currency symbol and international code of the underlying {@link
  * java.text.NumberFormat} object to the values of the last two arguments, respectively.
  * This method is invoked in the process of parsing, not formatting.
  *
  * Only invoke this from code synchronized on value of the first argument, and don't
  * forget to put the symbols back otherwise equals(), hashCode() and immutability will
  * break.  */
private static DecimalFormatSymbols setSymbolAndCode(DecimalFormat numberFormat, String symbol, String code) {
    checkState(Thread.holdsLock(numberFormat));
    DecimalFormatSymbols fs = numberFormat.getDecimalFormatSymbols();
    DecimalFormatSymbols ante = (DecimalFormatSymbols)fs.clone();
    fs.setInternationalCurrencySymbol(code);
    fs.setCurrencySymbol(symbol);
    numberFormat.setDecimalFormatSymbols(fs);
    return ante;
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:17,代码来源:BtcFormat.java

示例4: createCurrencyFormat

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public static DecimalFormat createCurrencyFormat(Currency c) {
	DecimalFormatSymbols dfs = new DecimalFormatSymbols();
	dfs.setDecimalSeparator(charOrEmpty(c.decimalSeparator, dfs.getDecimalSeparator()));
	dfs.setGroupingSeparator(charOrEmpty(c.groupSeparator, dfs.getGroupingSeparator()));
	dfs.setMonetaryDecimalSeparator(dfs.getDecimalSeparator());
	dfs.setCurrencySymbol(c.symbol);

	DecimalFormat df = new DecimalFormat("#,##0.00", dfs);
	df.setGroupingUsed(dfs.getGroupingSeparator() > 0);
	df.setMinimumFractionDigits(c.decimals);
	df.setMaximumFractionDigits(c.decimals);
	df.setDecimalSeparatorAlwaysShown(false);
	return df;
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:15,代码来源:CurrencyCache.java


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