本文整理匯總了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;
}