Java Code Examples for java.text.DecimalFormatSymbols#setMinusSign()

The following examples show how to use java.text.DecimalFormatSymbols#setMinusSign() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumberFormatter.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private DecimalFormatSymbols getICUDecimalSymbols( Locale locale )
{
	DecimalFormatSymbols symbols = new DecimalFormatSymbols( locale );
	com.ibm.icu.text.DecimalFormatSymbols icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(
			locale );
	symbols.setCurrencySymbol( icuSymbols.getCurrencySymbol( ) );
	symbols.setDecimalSeparator( icuSymbols.getDecimalSeparator( ) );
	symbols.setDigit( icuSymbols.getDigit( ) );
	symbols.setGroupingSeparator( icuSymbols.getGroupingSeparator( ) );
	symbols.setInfinity( icuSymbols.getInfinity( ) );
	symbols.setInternationalCurrencySymbol( icuSymbols
			.getInternationalCurrencySymbol( ) );
	symbols.setMinusSign( icuSymbols.getMinusSign( ) );
	symbols.setMonetaryDecimalSeparator( icuSymbols
			.getMonetaryDecimalSeparator( ) );
	symbols.setNaN( icuSymbols.getNaN( ) );
	symbols.setPatternSeparator( icuSymbols.getPatternSeparator( ) );
	symbols.setPercent( icuSymbols.getPercent( ) );
	symbols.setPerMill( icuSymbols.getPerMill( ) );
	symbols.setZeroDigit( icuSymbols.getZeroDigit( ) );
	return symbols;
}
 
Example 2
Source File: PrettyIntegerFormat.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * It is usually better to use {@link #getFormat()} to use a single instance of the formatter in the whole program.
 */
private PrettyIntegerFormat()
{
	// + and - should not need to be internationalized
	DecimalFormatSymbols decimalFormatSymbols = getDecimalFormatSymbols();
	decimalFormatSymbols.setMinusSign('\u2212');
	setDecimalFormatSymbols(decimalFormatSymbols);
	setPositivePrefix("+"); //$NON-NLS-1$
}
 
Example 3
Source File: ICalFloatFormatter.java    From biweekly with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Creates a new formatter.
 * @param decimals the max number of decimal places
 */
public ICalFloatFormatter(int decimals) {
	setMaximumFractionDigits(decimals);
	if (decimals > 0) {
		setMinimumFractionDigits(1);
	}

	//decimal separator differs by locale (e.g. Germany uses ",")
	DecimalFormatSymbols symbols = new DecimalFormatSymbols();
	symbols.setDecimalSeparator('.');
	symbols.setMinusSign('-');
	setDecimalFormatSymbols(symbols);
}
 
Example 4
Source File: PrettyIntegerFormat.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * It is usually better to use {@link #getFormat()} to use a single instance of the formatter in the whole program.
 */
private PrettyIntegerFormat()
{
	// + and - should not need to be internationalized
	DecimalFormatSymbols decimalFormatSymbols = getDecimalFormatSymbols();
	decimalFormatSymbols.setMinusSign('\u2212');
	setDecimalFormatSymbols(decimalFormatSymbols);
	setPositivePrefix("+"); //$NON-NLS-1$
}
 
Example 5
Source File: Tools.java    From cncgcodecontroller with MIT License 5 votes vote down vote up
@Override
protected DecimalFormat initialValue() 
{
    DecimalFormatSymbols s = new DecimalFormatSymbols();
    s.setDecimalSeparator('.');
    s.setMonetaryDecimalSeparator('.');
    s.setMinusSign('-');
    return new DecimalFormat("0.0000",s); 
}
 
Example 6
Source File: SakaiDecimalFormatSymbolsProvider.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public DecimalFormatSymbols getInstance(final Locale locale) throws IllegalArgumentException, NullPointerException {
	if (locale == null) {
		throw new NullPointerException("locale:null");
	} else if (!SakaiLocaleServiceProviderUtil.isAvailableLocale(locale)) {
		throw new IllegalArgumentException("locale:" + locale.toString());
	}

	DecimalFormatSymbols symbols = new DecimalFormatSymbols();
	symbols.setDecimalSeparator(
			SakaiLocaleServiceProviderUtil.getChar("DecimalSeparator", locale));
	symbols.setDigit(
			SakaiLocaleServiceProviderUtil.getChar("Digit", locale));
	symbols.setExponentSeparator(
			SakaiLocaleServiceProviderUtil.getString("ExponentSeparator", locale));
	symbols.setGroupingSeparator(
			SakaiLocaleServiceProviderUtil.getChar("GroupingSeparator", locale));
	symbols.setInfinity(
			SakaiLocaleServiceProviderUtil.getString("Infinity", locale));
	symbols.setInternationalCurrencySymbol(
			SakaiLocaleServiceProviderUtil.getString("InternationalCurrencySymbol", locale));
	symbols.setCurrencySymbol(
			SakaiLocaleServiceProviderUtil.getString("CurrencySymbol", locale));
	symbols.setMinusSign(
			SakaiLocaleServiceProviderUtil.getChar("MinusSign", locale));
	symbols.setMonetaryDecimalSeparator(
			SakaiLocaleServiceProviderUtil.getChar("MonetaryDecimalSeparator", locale));
	symbols.setNaN(
			SakaiLocaleServiceProviderUtil.getString("NaN", locale));
	symbols.setPatternSeparator(
			SakaiLocaleServiceProviderUtil.getChar("PatternSeparator", locale));
	symbols.setPercent(
			SakaiLocaleServiceProviderUtil.getChar("Percent", locale));
	symbols.setPerMill(
			SakaiLocaleServiceProviderUtil.getChar("PerMill", locale));
	symbols.setZeroDigit(
			SakaiLocaleServiceProviderUtil.getChar("ZeroDigit", locale));

	return symbols;
}
 
Example 7
Source File: SakaiDecimalFormatSymbolsProvider.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public DecimalFormatSymbols getInstance(final Locale locale) throws IllegalArgumentException, NullPointerException {
	if (locale == null) {
		throw new NullPointerException("locale:null");
	} else if (!SakaiLocaleServiceProviderUtil.isAvailableLocale(locale)) {
		throw new IllegalArgumentException("locale:" + locale.toString());
	}

	DecimalFormatSymbols symbols = new DecimalFormatSymbols();
	symbols.setDecimalSeparator(
			SakaiLocaleServiceProviderUtil.getChar("DecimalSeparator", locale));
	symbols.setDigit(
			SakaiLocaleServiceProviderUtil.getChar("Digit", locale));
	symbols.setExponentSeparator(
			SakaiLocaleServiceProviderUtil.getString("ExponentSeparator", locale));
	symbols.setGroupingSeparator(
			SakaiLocaleServiceProviderUtil.getChar("GroupingSeparator", locale));
	symbols.setInfinity(
			SakaiLocaleServiceProviderUtil.getString("Infinity", locale));
	symbols.setInternationalCurrencySymbol(
			SakaiLocaleServiceProviderUtil.getString("InternationalCurrencySymbol", locale));
	symbols.setCurrencySymbol(
			SakaiLocaleServiceProviderUtil.getString("CurrencySymbol", locale));
	symbols.setMinusSign(
			SakaiLocaleServiceProviderUtil.getChar("MinusSign", locale));
	symbols.setMonetaryDecimalSeparator(
			SakaiLocaleServiceProviderUtil.getChar("MonetaryDecimalSeparator", locale));
	symbols.setNaN(
			SakaiLocaleServiceProviderUtil.getString("NaN", locale));
	symbols.setPatternSeparator(
			SakaiLocaleServiceProviderUtil.getChar("PatternSeparator", locale));
	symbols.setPercent(
			SakaiLocaleServiceProviderUtil.getChar("Percent", locale));
	symbols.setPerMill(
			SakaiLocaleServiceProviderUtil.getChar("PerMill", locale));
	symbols.setZeroDigit(
			SakaiLocaleServiceProviderUtil.getChar("ZeroDigit", locale));

	return symbols;
}