/** * Get the "grouping-separator" attribute. * grouping-separator specifies the character used as a grouping * (e.g. thousands) separator; the default value is the comma character (,). * * @return Character to use a grouping separator */ public char getGroupingSeparator() { return m_dfs.getGroupingSeparator(); }
/** * Get the "grouping-separator" attribute. * grouping-separator specifies the character used as a grouping * (e.g. thousands) separator; the default value is the comma character (,). * * @return Character to use a grouping separator */ public char getGroupingSeparator() { return m_dfs.getGroupingSeparator(); }
private String getNumeral(String digit, String nonZeroDigit) { String groupSeparator = "\\" + decimalFormat.getDecimalFormatSymbols().getGroupingSeparator(); String groupedNumeral = "(" + nonZeroDigit + digit + "?" + digit + "?" + "(" + groupSeparator + digit + digit + digit + ")+)"; return "((" + digit + "++)|" + groupedNumeral + ")"; }
private String localiseFormat(String format) { DecimalFormatSymbols dfs = getDecimalFormatSymbols(); if(format.contains(",") && dfs.getGroupingSeparator() != ',') { if(format.contains(".") && dfs.getDecimalSeparator() != '.') { format = replaceLast(format, "\\.", "[DECIMAL_SEPARATOR]"); format = format.replace(',', dfs.getGroupingSeparator()) .replace("[DECIMAL_SEPARATOR]", Character.toString(dfs.getDecimalSeparator())); } else { format = format.replace(',', dfs.getGroupingSeparator()); } } else if(format.contains(".") && dfs.getDecimalSeparator() != '.') { format = format.replace('.', dfs.getDecimalSeparator()); } return format; }
/** * The {@link NumberFormat} to use for parsing numbers. If unset the US * locale will be used ('.' as decimal place). * @param numberFormat the {@link NumberFormat} to use for number parsing */ public final void setNumberFormat(NumberFormat numberFormat) { this.numberFormat = numberFormat; if (numberFormat instanceof DecimalFormat) { grouping = "" + ((DecimalFormat) numberFormat).getDecimalFormatSymbols().getGroupingSeparator(); decimal = "" + ((DecimalFormat) numberFormat).getDecimalFormatSymbols().getDecimalSeparator(); } }
private String getCalculatedThousandSeparator() { String thousandSeparator = (String) getStateHelper().eval("thousandSeparator", null); if (thousandSeparator == null) { Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale); thousandSeparator = Character.toString(decimalFormatSymbols.getGroupingSeparator()); } return thousandSeparator; }
@Override public void setDefault() { int i, nrfields = 0; allocate( nrfields ); DecimalFormat decimalFormat = new DecimalFormat(); for ( i = 0; i < nrfields; i++ ) { fieldName[i] = "field" + i; fieldType[i] = "Number"; fieldFormat[i] = "\u00A40,000,000.00;\u00A4-0,000,000.00"; fieldLength[i] = 9; fieldPrecision[i] = 2; currency[i] = decimalFormat.getDecimalFormatSymbols().getCurrencySymbol(); decimal[i] = new String( new char[] { decimalFormat.getDecimalFormatSymbols().getDecimalSeparator() } ); group[i] = new String( new char[] { decimalFormat.getDecimalFormatSymbols().getGroupingSeparator() } ); setEmptyString[i] = false; } dataLines = new ArrayList<List<String>>(); }
boolean negative = removeLocaleSign(tokenBuilder); String groupSeparator = String.valueOf(dfs.getGroupingSeparator()); int separatorIndex = -1; while ((separatorIndex = tokenBuilder.indexOf(groupSeparator)) != -1) {
public void setDefault() { int i, nrfields = 0; allocate( nrfields ); DecimalFormat decimalFormat = new DecimalFormat(); for ( i = 0; i < nrfields; i++ ) { fieldName[i] = "field" + i; fieldType[i] = "Number"; fieldFormat[i] = "\u00A40,000,000.00;\u00A4-0,000,000.00"; fieldLength[i] = 9; fieldPrecision[i] = 2; currency[i] = decimalFormat.getDecimalFormatSymbols().getCurrencySymbol(); decimal[i] = new String( new char[] { decimalFormat.getDecimalFormatSymbols().getDecimalSeparator() } ); group[i] = new String( new char[] { decimalFormat.getDecimalFormatSymbols().getGroupingSeparator() } ); value[i] = "-"; setEmptyString[i] = false; } }
String groupingSeparator = Character.toString(dfs.getGroupingSeparator()); for (strip = 0; strip < pos; strip++) { char resultCh = result.charAt(strip); if (resultCh != '0' && resultCh != dfs.getGroupingSeparator()) { break;
public void setDefault() { int i, nrfields = 0; allocate( nrfields ); DecimalFormat decimalFormat = new DecimalFormat(); for ( i = 0; i < nrfields; i++ ) { fieldName[i] = "field" + i; fieldType[i] = "Number"; fieldFormat[i] = "\u00A40,000,000.00;\u00A4-0,000,000.00"; fieldLength[i] = 9; fieldPrecision[i] = 2; currency[i] = decimalFormat.getDecimalFormatSymbols().getCurrencySymbol(); decimal[i] = new String( new char[] { decimalFormat.getDecimalFormatSymbols().getDecimalSeparator() } ); group[i] = new String( new char[] { decimalFormat.getDecimalFormatSymbols().getGroupingSeparator() } ); value[i] = "-"; setEmptyString[i] = false; } rowLimit = "10"; neverEnding = false; intervalInMs = "5000"; rowTimeField = "now"; lastTimeField = "FiveSecondsAgo"; }
char separator = new DecimalFormatSymbols(locale).getGroupingSeparator(); int size = ((DecimalFormat) NumberFormat.getNumberInstance(locale)).getGroupingSize(); int offset = str.length() % size;
inilen = et.getText().length(); String v = s.toString().replace(String.valueOf(df.getDecimalFormatSymbols().getGroupingSeparator()), ""); Number n = df.parse(v); int cp = et.getSelectionStart();
case DEFAULT : final DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale); symbols.setGroupingSeparator(dfs.getGroupingSeparator()); break; case NONE :
public NativeDecimalFormat(String pattern, DecimalFormatSymbols dfs) { try { this.address = open(pattern, dfs.getCurrencySymbol(), dfs.getDecimalSeparator(), dfs.getDigit(), dfs.getExponentSeparator(), dfs.getGroupingSeparator(), dfs.getInfinity(), dfs.getInternationalCurrencySymbol(), dfs.getMinusSign(), dfs.getMonetaryDecimalSeparator(), dfs.getNaN(), dfs.getPatternSeparator(), dfs.getPercent(), dfs.getPerMill(), dfs.getZeroDigit()); this.lastPattern = pattern; } catch (NullPointerException npe) { throw npe; } catch (RuntimeException re) { throw new IllegalArgumentException("syntax error: " + re.getMessage() + ": " + pattern); } }
/** * Copies the DecimalFormatSymbols settings into our native peer in bulk. */ public void setDecimalFormatSymbols(final DecimalFormatSymbols dfs) { setDecimalFormatSymbols(this.address, dfs.getCurrencySymbol(), dfs.getDecimalSeparator(), dfs.getDigit(), dfs.getExponentSeparator(), dfs.getGroupingSeparator(), dfs.getInfinity(), dfs.getInternationalCurrencySymbol(), dfs.getMinusSign(), dfs.getMonetaryDecimalSeparator(), dfs.getNaN(), dfs.getPatternSeparator(), dfs.getPercent(), dfs.getPerMill(), dfs.getZeroDigit()); }
conversionMeta.setTrimType( trimType ); conversionMeta.setDecimalSymbol( String.valueOf( currencyFormat.getDecimalFormatSymbols().getDecimalSeparator() ) ); conversionMeta.setGroupingSymbol( String.valueOf( currencyFormat.getDecimalFormatSymbols().getGroupingSeparator() ) ); conversionMeta.setCurrencySymbol( currencyFormat.getCurrency().getSymbol() ); conversionMeta.setLength( 15 );
data.dfs.setGroupingSeparator( field.getGroupingSymbol().charAt( 0 ) ); } else { data.dfs.setGroupingSeparator( data.defaultDecimalFormatSymbols.getGroupingSeparator() );
private void writeObject(ObjectOutputStream stream) throws IOException { ObjectOutputStream.PutField fields = stream.putFields(); fields.put("currencySymbol", currencySymbol); fields.put("decimalSeparator", getDecimalSeparator()); fields.put("digit", getDigit()); fields.put("exponential", exponentSeparator.charAt(0)); fields.put("exponentialSeparator", exponentSeparator); fields.put("groupingSeparator", getGroupingSeparator()); fields.put("infinity", infinity); fields.put("intlCurrencySymbol", intlCurrencySymbol); fields.put("minusSign", getMinusSign()); fields.put("monetarySeparator", getMonetaryDecimalSeparator()); fields.put("NaN", NaN); fields.put("patternSeparator", getPatternSeparator()); fields.put("percent", getPercent()); fields.put("perMill", getPerMill()); fields.put("serialVersionOnStream", 3); fields.put("zeroDigit", getZeroDigit()); fields.put("locale", locale); stream.writeFields(); }
@Test public void testAppend_FormattedString() { StrBuilder sb; sb = new StrBuilder(); sb.append("Hi", (Object[]) null); assertEquals("Hi", sb.toString()); sb = new StrBuilder(); sb.append("Hi", "Alice"); assertEquals("Hi", sb.toString()); sb = new StrBuilder(); sb.append("Hi %s", "Alice"); assertEquals("Hi Alice", sb.toString()); sb = new StrBuilder(); sb.append("Hi %s %,d", "Alice", 5000); // group separator depends on system locale final char groupingSeparator = DecimalFormatSymbols.getInstance().getGroupingSeparator(); final String expected = "Hi Alice 5" + groupingSeparator + "000"; assertEquals(expected, sb.toString()); }