當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。