本文整理汇总了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.
}
示例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);
}
}
示例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;
}
示例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;
}