Java Code Examples for java.text.DecimalFormatSymbols#setNaN()
The following examples show how to use
java.text.DecimalFormatSymbols#setNaN() .
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: NonBlockingStatsDClient.java From java-dogstatsd-client with MIT License | 6 votes |
private static NumberFormat newFormatter(boolean sampler) { // Always create the formatter for the US locale in order to avoid this bug: // https://github.com/indeedeng/java-dogstatsd-client/issues/3 NumberFormat numberFormatter = NumberFormat.getInstance(Locale.US); numberFormatter.setGroupingUsed(false); // we need to specify a value for Double.NaN that is recognized by dogStatsD if (numberFormatter instanceof DecimalFormat) { // better safe than a runtime error final DecimalFormat decimalFormat = (DecimalFormat) numberFormatter; final DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols(); symbols.setNaN("NaN"); decimalFormat.setDecimalFormatSymbols(symbols); } if (sampler) { numberFormatter.setMinimumFractionDigits(6); } else { numberFormatter.setMaximumFractionDigits(6); } return numberFormatter; }
Example 2
Source File: NumberFormatter.java From birt with Eclipse Public License 1.0 | 6 votes |
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 3
Source File: NumericalMatrix.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
private NumericalMatrix() { formatter = new DecimalFormat(); DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(); decimalFormatSymbols.setNaN("?"); formatter.setDecimalFormatSymbols(decimalFormatSymbols); formatter.setMaximumFractionDigits(3); formatter.setMinimumFractionDigits(3); }
Example 4
Source File: StringFormatting.java From thunderstorm with GNU General Public License v3.0 | 5 votes |
public static DecimalFormat getDecimalFormat(int floatPrecision) { DecimalFormat df = new DecimalFormat(); DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(Locale.US); symbols.setInfinity("Infinity"); symbols.setNaN("NaN"); df.setDecimalFormatSymbols(symbols); df.setGroupingUsed(false); df.setRoundingMode(RoundingMode.HALF_EVEN); df.setMaximumFractionDigits(floatPrecision); return df; }
Example 5
Source File: DecimalFormatTest.java From j2objc with Apache License 2.0 | 5 votes |
public void test_setNan_emptyString() throws Exception { DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setNaN(""); DecimalFormat df = new DecimalFormat(); df.setDecimalFormatSymbols(dfs); df.format(Double.NaN); }
Example 6
Source File: DecimalFormatSymbolsTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * @tests serialization/deserialization compatibility with RI6. */ public void testSerializationCompatibility() throws Exception { DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US); symbols.setExponentSeparator("EE"); symbols.setNaN("NaN"); SerializationTest.verifyGolden(this, symbols); }
Example 7
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private static JSpinner makeSpinner2(SpinnerNumberModel m) { JSpinner s = new JSpinner(m); JFormattedTextField ftf = getJFormattedTextField(s); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setNaN(" "); ftf.setFormatterFactory(makeFFactory(dfs)); return s; }
Example 8
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private static JSpinner makeSpinner3(SpinnerNumberModel m) { JSpinner s = new JSpinner(m); JFormattedTextField ftf = getJFormattedTextField(s); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setNaN("----"); ftf.setFormatterFactory(makeFFactory(dfs)); return s; }
Example 9
Source File: SakaiDecimalFormatSymbolsProvider.java From sakai with Educational Community License v2.0 | 4 votes |
/** * {@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 10
Source File: SakaiDecimalFormatSymbolsProvider.java From sakai with Educational Community License v2.0 | 4 votes |
/** * {@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; }