Java Code Examples for java.text.DecimalFormatSymbols#setGroupingSeparator()
The following examples show how to use
java.text.DecimalFormatSymbols#setGroupingSeparator() .
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: CDecimalFormatter.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
/** * creates a decimal formatter from the server message * * @param reader reader of the message coming from the server * @throws OLcRemoteException if anything bad happens on the server * @throws IOException if a problem happens during the message * transmission */ public CDecimalFormatter(MessageReader reader) throws OLcRemoteException, IOException { reader.returnNextStartStructure("DEF"); minimum = reader.returnNextDecimalField("MIN"); maximum = reader.returnNextDecimalField("MAX"); linear = reader.returnNextBooleanField("LIN"); colorscheme = reader.returnNextBooleanField("CLS"); reader.returnNextEndStructure("DEF"); String formatfordecimalstring = "###,###.###"; formatfordecimal = new DecimalFormat(formatfordecimalstring); DecimalFormatSymbols formatforsymbol = formatfordecimal.getDecimalFormatSymbols(); formatforsymbol.setGroupingSeparator(' '); formatforsymbol.setDecimalSeparator('.'); formatfordecimal.setDecimalFormatSymbols(formatforsymbol); formatfordecimal.setParseBigDecimal(true); }
Example 2
Source File: TestShrinkAuxiliaryData.java From hottub with GNU General Public License v2.0 | 6 votes |
private void printTestInfo(int maxCacheSize) { DecimalFormat grouped = new DecimalFormat("000,000"); DecimalFormatSymbols formatSymbols = grouped.getDecimalFormatSymbols(); formatSymbols.setGroupingSeparator(' '); grouped.setDecimalFormatSymbols(formatSymbols); System.out.format( "Test will use %s bytes of memory of %s available%n" + "Available memory is %s with %d bytes pointer size - can save %s pointers%n" + "Max cache size: 2^%d = %s elements%n", grouped.format(ShrinkAuxiliaryDataTest.getMemoryUsedByTest()), grouped.format(Runtime.getRuntime().maxMemory()), grouped.format(Runtime.getRuntime().maxMemory() - ShrinkAuxiliaryDataTest.getMemoryUsedByTest()), Unsafe.ADDRESS_SIZE, grouped.format((Runtime.getRuntime().freeMemory() - ShrinkAuxiliaryDataTest.getMemoryUsedByTest()) / Unsafe.ADDRESS_SIZE), maxCacheSize, grouped.format((int) Math.pow(2, maxCacheSize)) ); }
Example 3
Source File: TestShrinkAuxiliaryData.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private void printTestInfo(int maxCacheSize) { DecimalFormat grouped = new DecimalFormat("000,000"); DecimalFormatSymbols formatSymbols = grouped.getDecimalFormatSymbols(); formatSymbols.setGroupingSeparator(' '); grouped.setDecimalFormatSymbols(formatSymbols); System.out.format( "Test will use %s bytes of memory of %s available%n" + "Available memory is %s with %d bytes pointer size - can save %s pointers%n" + "Max cache size: 2^%d = %s elements%n", grouped.format(ShrinkAuxiliaryDataTest.getMemoryUsedByTest()), grouped.format(Runtime.getRuntime().maxMemory()), grouped.format(Runtime.getRuntime().maxMemory() - ShrinkAuxiliaryDataTest.getMemoryUsedByTest()), Unsafe.ADDRESS_SIZE, grouped.format((Runtime.getRuntime().freeMemory() - ShrinkAuxiliaryDataTest.getMemoryUsedByTest()) / Unsafe.ADDRESS_SIZE), maxCacheSize, grouped.format((int) Math.pow(2, maxCacheSize)) ); }
Example 4
Source File: TestShrinkAuxiliaryData.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private void printTestInfo(int maxCacheSize) { DecimalFormat grouped = new DecimalFormat("000,000"); DecimalFormatSymbols formatSymbols = grouped.getDecimalFormatSymbols(); formatSymbols.setGroupingSeparator(' '); grouped.setDecimalFormatSymbols(formatSymbols); System.out.format( "Test will use %s bytes of memory of %s available%n" + "Available memory is %s with %d bytes pointer size - can save %s pointers%n" + "Max cache size: 2^%d = %s elements%n", grouped.format(ShrinkAuxiliaryDataTest.getMemoryUsedByTest()), grouped.format(Runtime.getRuntime().maxMemory()), grouped.format(Runtime.getRuntime().maxMemory() - ShrinkAuxiliaryDataTest.getMemoryUsedByTest()), Unsafe.ADDRESS_SIZE, grouped.format((Runtime.getRuntime().freeMemory() - ShrinkAuxiliaryDataTest.getMemoryUsedByTest()) / Unsafe.ADDRESS_SIZE), maxCacheSize, grouped.format((int) Math.pow(2, maxCacheSize)) ); }
Example 5
Source File: TestShrinkAuxiliaryData.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void printTestInfo(int maxCacheSize) { DecimalFormat grouped = new DecimalFormat("000,000"); DecimalFormatSymbols formatSymbols = grouped.getDecimalFormatSymbols(); formatSymbols.setGroupingSeparator(' '); grouped.setDecimalFormatSymbols(formatSymbols); System.out.format( "Test will use %s bytes of memory of %s available%n" + "Available memory is %s with %d bytes pointer size - can save %s pointers%n" + "Max cache size: 2^%d = %s elements%n", grouped.format(ShrinkAuxiliaryDataTest.getMemoryUsedByTest()), grouped.format(Runtime.getRuntime().maxMemory()), grouped.format(Runtime.getRuntime().maxMemory() - ShrinkAuxiliaryDataTest.getMemoryUsedByTest()), Unsafe.ADDRESS_SIZE, grouped.format((Runtime.getRuntime().freeMemory() - ShrinkAuxiliaryDataTest.getMemoryUsedByTest()) / Unsafe.ADDRESS_SIZE), maxCacheSize, grouped.format((int) Math.pow(2, maxCacheSize)) ); }
Example 6
Source File: AmountToSendActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
@OnClick(R.id.btn_max) public void maxAmount(View view) { if (balance != null && !balance.equals(new BigDecimal(0))) { DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(); symbols.setDecimalSeparator('.'); symbols.setGroupingSeparator(','); DecimalFormat decimalFormat = new DecimalFormat(ETH_SHOW_PATTERN, symbols); decimalFormat.setRoundingMode(RoundingMode.FLOOR); String clearAmount = decimalFormat.format(balance).replace(",",""); etAmountToSend.setText(clearAmount); inputLayout.setCurrentText(clearAmount); etAmountToSend.setSelection(etAmountToSend.getText().length()); } }
Example 7
Source File: AmountToSendActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
@OnClick(R.id.btn_max) public void maxAmount(View view) { if (balance != null && !balance.equals(new BigDecimal(0))) { DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(); symbols.setDecimalSeparator('.'); symbols.setGroupingSeparator(','); DecimalFormat decimalFormat = new DecimalFormat(ETH_SHOW_PATTERN, symbols); decimalFormat.setRoundingMode(RoundingMode.FLOOR); String clearAmount = decimalFormat.format(balance).replace(",",""); etAmountToSend.setText(clearAmount); inputLayout.setCurrentText(clearAmount); etAmountToSend.setSelection(etAmountToSend.getText().length()); } }
Example 8
Source File: NumberTextWatcher.java From fingen with Apache License 2.0 | 5 votes |
public NumberTextWatcher(EditText et, TextWatcher textWatcher) { mTextWatcher = textWatcher; DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setDecimalSeparator('.'); symbols.setGroupingSeparator(' '); df = new DecimalFormat("#,###.##"); df.setDecimalSeparatorAlwaysShown(true); df.setDecimalFormatSymbols(symbols); dfnd = new DecimalFormat("#,###"); dfnd.setDecimalFormatSymbols(symbols); this.et = et; hasFractionalPart = false; }
Example 9
Source File: AmountToSendActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
@OnClick(R.id.btn_max) public void maxAmount(View view) { if (balance != null && !balance.equals(new BigDecimal(0))) { DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(); symbols.setDecimalSeparator('.'); symbols.setGroupingSeparator(','); DecimalFormat decimalFormat = new DecimalFormat(Common.ETH_SHOW_PATTERN, symbols); decimalFormat.setRoundingMode(RoundingMode.FLOOR); String clearAmount = decimalFormat.format(balance).replace(",",""); etAmountToSend.setText(clearAmount); inputLayout.setCurrentText(clearAmount); etAmountToSend.setSelection(etAmountToSend.getText().length()); } }
Example 10
Source File: AmountToSendActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
private void updateTokenBalance(){ balance = tokenManager.getTokenByCode(tokenCode).getTokenNum(); DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(); symbols.setDecimalSeparator('.'); symbols.setGroupingSeparator(','); DecimalFormat decimalFormat = new DecimalFormat(ETH_SHOW_PATTERN, symbols); decimalFormat.setRoundingMode(RoundingMode.DOWN); if (balance != null && !balance.equals(new BigDecimal(0))) { setCurrentBalance(decimalFormat.format(balance), tokenCode.toUpperCase()); } }
Example 11
Source File: AmountToSendActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
@OnClick(R.id.btn_max) public void maxAmount(View view) { if (balance != null && !balance.equals(new BigDecimal(0))) { DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(); symbols.setDecimalSeparator('.'); symbols.setGroupingSeparator(','); DecimalFormat decimalFormat = new DecimalFormat(ETH_SHOW_PATTERN, symbols); decimalFormat.setRoundingMode(RoundingMode.FLOOR); String clearAmount = decimalFormat.format(balance).replace(",",""); etAmountToSend.setText(clearAmount); inputLayout.setCurrentText(clearAmount); etAmountToSend.setSelection(etAmountToSend.getText().length()); } }
Example 12
Source File: DecimalFormatUtil.java From RxAndroidBootstrap with Apache License 2.0 | 5 votes |
/** * Returns a thousans separated decimar formatter. * * @return */ public static DecimalFormat getThousandSeperatedDecimalFormat() { DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(Locale.US); DecimalFormatSymbols symbols = df.getDecimalFormatSymbols(); symbols.setGroupingSeparator(' '); df.setDecimalFormatSymbols(symbols); return df; }
Example 13
Source File: CabbageFormatter.java From fingen with Apache License 2.0 | 5 votes |
public synchronized String format(BigDecimal amount){ if (mCabbage != null) { mNumberFormat.setMinimumFractionDigits(mCabbage.getDecimalCount()); mNumberFormat.setMaximumFractionDigits(mCabbage.getDecimalCount()); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setCurrencySymbol(mCabbage.getSimbol()); dfs.setGroupingSeparator(' '); dfs.setMonetaryDecimalSeparator('.'); ((DecimalFormat) mNumberFormat).setDecimalFormatSymbols(dfs); return mNumberFormat.format(amount.setScale(mCabbage.getDecimalCount(), mRoundingMode)); } else { return ""; } }
Example 14
Source File: NormalValuesFormatter.java From fingen with Apache License 2.0 | 5 votes |
public NormalValuesFormatter() { mFormat = NumberFormat.getCurrencyInstance(); mFormat.setMinimumFractionDigits(0); mFormat.setMaximumFractionDigits(2); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setCurrencySymbol(""); dfs.setGroupingSeparator(' '); dfs.setMonetaryDecimalSeparator('.'); ((DecimalFormat) mFormat).setDecimalFormatSymbols(dfs); }
Example 15
Source File: Value.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public Value num2str( String format, String decimalSymbol, String groupingSymbol, String currencySymbol ) throws KettleValueException { if ( isNull() ) { setType( VALUE_TYPE_STRING ); } else { // Number to String conversion... if ( getType() == VALUE_TYPE_NUMBER || getType() == VALUE_TYPE_INTEGER ) { NumberFormat nf = NumberFormat.getInstance(); DecimalFormat df = (DecimalFormat) nf; DecimalFormatSymbols dfs = new DecimalFormatSymbols(); if ( currencySymbol != null && currencySymbol.length() > 0 ) { dfs.setCurrencySymbol( currencySymbol ); } if ( groupingSymbol != null && groupingSymbol.length() > 0 ) { dfs.setGroupingSeparator( groupingSymbol.charAt( 0 ) ); } if ( decimalSymbol != null && decimalSymbol.length() > 0 ) { dfs.setDecimalSeparator( decimalSymbol.charAt( 0 ) ); } df.setDecimalFormatSymbols( dfs ); // in case of 4, 3 or 2 if ( format != null && format.length() > 0 ) { df.applyPattern( format ); } try { setValue( nf.format( getNumber() ) ); } catch ( Exception e ) { setType( VALUE_TYPE_STRING ); setNull(); throw new KettleValueException( "Couldn't convert Number to String " + e.toString() ); } } else { throw new KettleValueException( "Function NUM2STR only works on Numbers and Integers" ); } } return this; }
Example 16
Source File: TransformForm.java From Ultraino with MIT License | 5 votes |
public static String transformToText(Transform t){ DecimalFormat dFormat4 = new DecimalFormat("0.0000"); DecimalFormat dFormat1 = new DecimalFormat("0.0"); DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(); otherSymbols.setDecimalSeparator('.'); otherSymbols.setGroupingSeparator(','); dFormat4.setDecimalFormatSymbols(otherSymbols); dFormat1.setDecimalFormatSymbols(otherSymbols); StringBuilder sb = new StringBuilder(); Vector3f trans = t.getTranslation(); sb.append( dFormat4.format(trans.x) ).append(" "); sb.append( dFormat4.format(trans.y) ).append(" "); sb.append( dFormat4.format(trans.z) ).append(" "); final Vector3f angles = t.getRotation().toAngles(null).multLocal( M.RAD_TO_DEG ); sb.append(dFormat1.format( angles.x ) ).append(" "); sb.append(dFormat1.format( angles.y ) ).append(" "); sb.append(dFormat1.format( angles.z ) ).append(" "); Vector3f scale = t.getScale(); sb.append( dFormat4.format(scale.x) ).append(" "); sb.append( dFormat4.format(scale.y) ).append(" "); sb.append( dFormat4.format(scale.z) ); return sb.toString(); }
Example 17
Source File: AmountNumberToken.java From jsr354-ri with Apache License 2.0 | 5 votes |
private void fixThousandsSeparatorWithSpace(DecimalFormatSymbols symbols) { if(Character.isSpaceChar(formatFormat.getDecimalFormatSymbols().getGroupingSeparator())){ symbols.setGroupingSeparator(' '); } if(Character.isWhitespace(formatFormat.getDecimalFormatSymbols().getDecimalSeparator())){ symbols.setDecimalSeparator(' '); } if(Character.isWhitespace(formatFormat.getDecimalFormatSymbols().getMonetaryDecimalSeparator())){ symbols.setMonetaryDecimalSeparator(' '); } }
Example 18
Source File: ExecutionTimeFormatter.java From quickperf with Apache License 2.0 | 5 votes |
private DecimalFormat buildFormatWithSpaceGroupingSeparator() { DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(Locale.ENGLISH); DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols(); symbols.setGroupingSeparator(' '); decimalFormat.setDecimalFormatSymbols(symbols); return decimalFormat; }
Example 19
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 20
Source File: JdbcResultSet.java From ignite with Apache License 2.0 | 3 votes |
/** {@inheritDoc} */ @Override protected DecimalFormat initialValue() { DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setGroupingSeparator(','); symbols.setDecimalSeparator('.'); String ptrn = "#,##0.0#"; DecimalFormat decimalFormat = new DecimalFormat(ptrn, symbols); decimalFormat.setParseBigDecimal(true); return decimalFormat; }