本文整理匯總了Java中java.text.DecimalFormatSymbols.getMonetaryDecimalSeparator方法的典型用法代碼示例。如果您正苦於以下問題:Java DecimalFormatSymbols.getMonetaryDecimalSeparator方法的具體用法?Java DecimalFormatSymbols.getMonetaryDecimalSeparator怎麽用?Java DecimalFormatSymbols.getMonetaryDecimalSeparator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.text.DecimalFormatSymbols
的用法示例。
在下文中一共展示了DecimalFormatSymbols.getMonetaryDecimalSeparator方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: withLocale
import java.text.DecimalFormatSymbols; //導入方法依賴的package包/類
/**
* Configure this instance with values from a {@link Locale}.
*/
public MonetaryFormat withLocale(Locale locale) {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
char negativeSign = dfs.getMinusSign();
char zeroDigit = dfs.getZeroDigit();
char decimalMark = dfs.getMonetaryDecimalSeparator();
return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups,
shift, roundingMode, codes, codeSeparator, codePrefixed);
}
示例2: initSettings
import java.text.DecimalFormatSymbols; //導入方法依賴的package包/類
/***
* If user does not provide a valid locale it throws IllegalArgumentException.
*
* If throws an IllegalArgumentException the locale sets to default locale
*/
private void initSettings() {
boolean success = false;
while (!success) {
try {
fractionDigit = Currency.getInstance(locale).getDefaultFractionDigits();
DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale);
if (mGroupDivider > 0)
symbols.setGroupingSeparator(mGroupDivider);
groupDivider = symbols.getGroupingSeparator();
if (mMonetaryDivider > 0)
symbols.setMonetaryDecimalSeparator(mMonetaryDivider);
monetaryDivider = symbols.getMonetaryDecimalSeparator();
currencySymbol = symbols.getCurrencySymbol();
DecimalFormat df = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale);
numberFormat = new DecimalFormat(df.toPattern(), symbols);
success = true;
} catch (IllegalArgumentException e) {
Log.e(getClass().getCanonicalName(), e.getMessage());
locale = getDefaultLocale();
}
}
}