/** * Get the "decimal-separator" attribute. * decimal-separator specifies the character used for the decimal sign; * the default value is the period character (.). * * @return the character to use as decimal separator */ public char getDecimalSeparator() { return m_dfs.getDecimalSeparator(); }
/** * Get the "decimal-separator" attribute. * decimal-separator specifies the character used for the decimal sign; * the default value is the period character (.). * * @return the character to use as decimal separator */ public char getDecimalSeparator() { return m_dfs.getDecimalSeparator(); }
DecimalFormat format=DecimalFormat.getInstance(); DecimalFormatSymbols symbols=format.getDecimalFormatSymbols(); char sep=symbols.getDecimalSeparator();
protected static int determinePrecision( String numericFormat ) { if ( numericFormat != null ) { char decimalSymbol = ( (DecimalFormat) NumberFormat.getInstance() ).getDecimalFormatSymbols().getDecimalSeparator(); int loc = numericFormat.lastIndexOf( decimalSymbol ); if ( loc >= 0 && loc < numericFormat.length() ) { Matcher m = PRECISION_PATTERN.matcher( numericFormat.substring( loc + 1 ) ); int nonDigitLoc = numericFormat.length(); if ( m.find() ) { nonDigitLoc = loc + 1 + m.start(); } return numericFormat.substring( loc + 1, nonDigitLoc ).length(); } else { return 0; } } else { return 0; } }
public static boolean isStringNumeric( String str ) { DecimalFormatSymbols currentLocaleSymbols = DecimalFormatSymbols.getInstance(); char localeMinusSign = currentLocaleSymbols.getMinusSign(); if ( !Character.isDigit( str.charAt( 0 ) ) && str.charAt( 0 ) != localeMinusSign ) return false; boolean isDecimalSeparatorFound = false; char localeDecimalSeparator = currentLocaleSymbols.getDecimalSeparator(); for ( char c : str.substring( 1 ).toCharArray() ) { if ( !Character.isDigit( c ) ) { if ( c == localeDecimalSeparator && !isDecimalSeparatorFound ) { isDecimalSeparatorFound = true; continue; } return false; } } return true; }
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; }
private String getCalculatedDecimalSepartor() { String decimalSeparator = (String) getStateHelper().eval("decimalSeparator", null); if (decimalSeparator == null) { Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale); decimalSeparator = Character.toString(decimalFormatSymbols.getDecimalSeparator()); } return decimalSeparator; }
private void writeFractional(StringBuffer result, StringBuffer output) { int digit; int strip; if (fractionalSpecials.size() > 0) { String decimalSeparator = Character.toString(getDecimalFormatSymbols().getDecimalSeparator()); digit = result.indexOf(decimalSeparator) + 1; if (exponent != null) { strip = result.indexOf("e") - 1; } else { strip = result.length() - 1; } while (strip > digit && result.charAt(strip) == '0') { strip--; } for (Special s : fractionalSpecials) { char resultCh = result.charAt(digit); if (resultCh != '0' || s.ch == '0' || digit < strip) { output.setCharAt(s.pos, resultCh); } else if (s.ch == '?') { // This is when we're in trailing zeros, and the format is '?'. // We still strip out remaining '#'s later output.setCharAt(s.pos, ' '); } digit++; } } }
String decimalSeparator = String.valueOf(dfs.getDecimalSeparator()); separatorIndex = tokenBuilder.indexOf(decimalSeparator); StringBuilder result = new StringBuilder("");
/** * 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(); } }
@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>>(); }
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; } }
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"; }
case DEFAULT : final DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale); symbols.setDecimalSeparator(dfs.getDecimalSeparator()); break; case NONE :
private Pattern getFloatPattern() { if (decimalFormat == null) { decimalFormat = (DecimalFormat) NumberFormat.getInstance(locale); } if (cachedFloatPattern != null) { return cachedFloatPattern; } DecimalFormatSymbols dfs = decimalFormat.getDecimalFormatSymbols(); String digit = "([0-9]|(\\p{javaDigit}))"; String nonZeroDigit = "[\\p{javaDigit}&&[^0]]"; String numeral = getNumeral(digit, nonZeroDigit); String decimalSeparator = "\\" + dfs.getDecimalSeparator(); String decimalNumeral = "(" + numeral + "|" + numeral + decimalSeparator + digit + "*+|" + decimalSeparator + digit + "++)"; String exponent = "([eE][+-]?" + digit + "+)?"; String decimal = "(([-+]?" + decimalNumeral + "(" + exponent + "?)" + ")|" + "(" + addPositiveSign(decimalNumeral) + "(" + exponent + "?)" + ")|" + "(" + addNegativeSign(decimalNumeral) + "(" + exponent + "?)" + "))"; String hexFloat = "([-+]?0[xX][0-9a-fA-F]*\\.[0-9a-fA-F]+([pP][-+]?[0-9]+)?)"; String localNaN = dfs.getNaN(); String localeInfinity = dfs.getInfinity(); String nonNumber = "(NaN|\\Q" + localNaN + "\\E|Infinity|\\Q" + localeInfinity + "\\E)"; String signedNonNumber = "((([-+]?(" + nonNumber + ")))|" + "(" + addPositiveSign(nonNumber) + ")|" + "(" + addNegativeSign(nonNumber) + "))"; cachedFloatPattern = Pattern.compile(decimal + "|" + hexFloat + "|" + signedNonNumber); return cachedFloatPattern; }
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); } }
conversionMeta.setConversionMask( currencyMask ); conversionMeta.setTrimType( trimType ); conversionMeta.setDecimalSymbol( String.valueOf( currencyFormat.getDecimalFormatSymbols().getDecimalSeparator() ) ); conversionMeta.setGroupingSymbol( String.valueOf( currencyFormat.getDecimalFormatSymbols().getGroupingSeparator() ) ); conversionMeta.setCurrencySymbol( currencyFormat.getCurrency().getSymbol() );
/** * 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()); }
locale = (Locale) fields.get("locale", null); if (serialVersionOnStream == 0) { setMonetaryDecimalSeparator(getDecimalSeparator()); } else { setMonetaryDecimalSeparator(fields.get("monetarySeparator", '.'));
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(); }