当前位置: 首页>>代码示例>>Java>>正文


Java DecimalFormatSymbols.getDecimalSeparator方法代码示例

本文整理汇总了Java中java.text.DecimalFormatSymbols.getDecimalSeparator方法的典型用法代码示例。如果您正苦于以下问题:Java DecimalFormatSymbols.getDecimalSeparator方法的具体用法?Java DecimalFormatSymbols.getDecimalSeparator怎么用?Java DecimalFormatSymbols.getDecimalSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.text.DecimalFormatSymbols的用法示例。


在下文中一共展示了DecimalFormatSymbols.getDecimalSeparator方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rebuildConstants

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/**
 * If the locale changes, but the app is still in memory, you may need to rebuild these constants
 */
public static void rebuildConstants() {
    DECIMAL_FORMAT = new DecimalFormatSymbols();

    // These will already be known by Java
    DECIMAL_POINT = DECIMAL_FORMAT.getDecimalSeparator();
    DECIMAL_SEPARATOR = DECIMAL_FORMAT.getGroupingSeparator();

    // Use a space for Bin and Hex
    BINARY_SEPARATOR = ' ';
    HEXADECIMAL_SEPARATOR = ' ';

    // We have to be careful with the Matrix Separator.
    // It defaults to "," but that's a common decimal point.
    if (DECIMAL_POINT == ',') MATRIX_SEPARATOR = ';';
    else MATRIX_SEPARATOR = ',';

    String number = "A-F0-9" +
            Pattern.quote(String.valueOf(DECIMAL_POINT)) +
            Pattern.quote(String.valueOf(DECIMAL_SEPARATOR)) +
            Pattern.quote(String.valueOf(BINARY_SEPARATOR)) +
            Pattern.quote(String.valueOf(HEXADECIMAL_SEPARATOR));

    REGEX_NUMBER = "[" + number + "]";
    REGEX_NOT_NUMBER = "[^" + number + "]";
}
 
开发者ID:tranleduy2000,项目名称:floating_calc,代码行数:29,代码来源:Constants.java

示例2: validateOnlyDigits

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/**
 * Validates that the given value contains only digits, but not e.g. a
 * character 'd'. Java would interpret the input 3d as double value 3.0.
 * Anyway, this must not succeed.
 * 
 * @param valueToCheck
 *            The value to be checked.
 * @param component
 *            The current component.
 * @return <code>true</code> if the value is valid.
 */
private static boolean validateOnlyDigits(String valueToCheck,
        FacesContext facesContext) {
    Locale locale = LocaleHandler.getLocaleFromString(BaseBean
            .getUserFromSession(facesContext).getLocale());
    DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
    boolean decSepFound = false;

    for (char c : valueToCheck.toCharArray()) {
        if (!decSepFound && c == dfs.getDecimalSeparator()) {
            decSepFound = true;
            continue;
        }
        if (c == dfs.getGroupingSeparator()) {
            continue;
        }
        if (!Character.isDigit(c)) {
            return false;
        }
    }

    return true;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:34,代码来源:DurationValidation.java

示例3: LocalizeWriter

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public LocalizeWriter(Writer out, Locale locale, boolean localizeDigits, boolean isUpperCase)
{
    super(out);
    this.locale = locale;
    this.localizeDigits = localizeDigits;
    this.isUpperCase = isUpperCase;
    if (locale != null)
    {
        DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale);
        this.zero = decimalFormatSymbols.getZeroDigit();
        this.decimalSeparator = decimalFormatSymbols.getDecimalSeparator();
    }
    else
    {
        this.zero = '0';
        this.decimalSeparator = '.';
    }
}
 
开发者ID:mtommila,项目名称:apfloat,代码行数:19,代码来源:FormattingHelper.java

示例4: setupLocaleSymbolsInputValidation

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/**
 * Setup user input validation allowed symbols according to current Locale and number type
 */
protected void setupLocaleSymbolsInputValidation() {

	Locale locale = LocalizationContext.getCurrent().filter(l -> l.isLocalized()).flatMap(l -> l.getLocale())
			.orElse(getLocale());
	if (locale == null) {
		// use default
		locale = Locale.getDefault();
	}

	// check grouping
	boolean useGrouping = true;
	if (getInternalField().getConverter() instanceof StringToNumberConverter) {
		NumberFormat nf = ((StringToNumberConverter<?>) getInternalField().getConverter()).getNumberFormat(locale);
		if (nf != null) {
			useGrouping = nf.isGroupingUsed();
		}
	}

	DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);

	char[] symbols = null;
	if (useGrouping) {
		if (TypeUtils.isDecimalNumber(getType())) {
			symbols = new char[] { dfs.getGroupingSeparator(), dfs.getDecimalSeparator() };
		} else {
			symbols = new char[] { dfs.getGroupingSeparator() };
		}
	} else {
		if (TypeUtils.isDecimalNumber(getType())) {
			symbols = new char[] { dfs.getDecimalSeparator() };
		}
	}

	getInternalField().setAllowedSymbols(symbols);
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:39,代码来源:NumberField.java

示例5: validatePrecision

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/**
 * Validates that the number of decimal places is not exceeding the amount
 * given in {@link DEC_PLACES_BOUND}.
 * 
 * @param valueToCheck
 *            The value to be checked.
 * @param component
 *            The current component.
 * @return <code>true</code> if the value is valid.
 */
private static boolean validatePrecision(String valueToCheck,
        FacesContext facesContext) {
    Locale locale = LocaleHandler.getLocaleFromString(BaseBean
            .getUserFromSession(facesContext).getLocale());
    DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
    char decimalSeparator = dfs.getDecimalSeparator();
    int pos = valueToCheck.lastIndexOf(decimalSeparator);
    if (pos != -1 && valueToCheck.length() - 1 > pos + DEC_PLACES_BOUND) {
        return false;
    } else {
        return true;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:24,代码来源:DurationValidation.java

示例6: doubleFromString

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
private static double doubleFromString(String sz, EditMode em) {
    if (sz.length() == 0)
        return 0.0;

    try {
        if (em == EditMode.HHMM) {
            String[] rgsz = sz.split(":");
            if (rgsz.length == 1)
                return (double) Integer.parseInt(sz);
            else if (rgsz.length == 2) {
                if (rgsz[0].length() == 0)
                    rgsz[0] = "0";
                switch (rgsz[1].length()) {
                    case 0:
                        rgsz[1] = "00";
                        break;
                    case 1:
                        rgsz[1] = String.format("%s0", rgsz[1]);
                        break;
                    case 2:
                        break;
                    default:
                        rgsz[1] = rgsz[1].substring(0, 2);
                }
                int h = Integer.parseInt(rgsz[0]);
                int m = Integer.parseInt(rgsz[1]);
                return h + (m / 60.0);
            } else
                return 0.0;
        } else {
            // TODO: remove this when Android bug 2626 is fixed. See http://code.google.com/p/android/issues/detail?id=2626&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars.
            DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.getDefault());
            char c = dfs.getDecimalSeparator();

            return m_df.parse(sz.replace('.', c).replace(',', c)).doubleValue();
        }
    } catch (Exception e) {
        return 0.0;
    }
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:41,代码来源:DecimalEdit.java

示例7: create

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
private static DecimalStyle create(Locale locale) {
    DecimalFormatSymbols oldSymbols = DecimalFormatSymbols.getInstance(locale);
    char zeroDigit = oldSymbols.getZeroDigit();
    char positiveSign = '+';
    char negativeSign = oldSymbols.getMinusSign();
    char decimalSeparator = oldSymbols.getDecimalSeparator();
    if (zeroDigit == '0' && negativeSign == '-' && decimalSeparator == '.') {
        return STANDARD;
    }
    return new DecimalStyle(zeroDigit, positiveSign, negativeSign, decimalSeparator);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:DecimalStyle.java

示例8: setupLocaleSymbolsInputValidation

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/**
 * Setup user input validation allowed symbols according to current Locale and number type
 */
protected void setupLocaleSymbolsInputValidation() {

	Locale locale = LocalizationContext.getCurrent().filter(l -> l.isLocalized()).flatMap(l -> l.getLocale())
			.orElse(getLocale());
	if (locale == null) {
		// use default
		locale = Locale.getDefault();
	}

	// check grouping
	boolean useGrouping = true;
	NumberFormat nf = getConverter().getNumberFormat(locale);
	if (nf != null) {
		useGrouping = nf.isGroupingUsed();
	}

	DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);

	char[] symbols = null;
	if (useGrouping) {
		if (TypeUtils.isDecimalNumber(getType())) {
			symbols = new char[] { dfs.getGroupingSeparator(), dfs.getDecimalSeparator() };
		} else {
			symbols = new char[] { dfs.getGroupingSeparator() };
		}
	} else {
		if (TypeUtils.isDecimalNumber(getType())) {
			symbols = new char[] { dfs.getDecimalSeparator() };
		}
	}

	getInternalField().setAllowedSymbols(symbols);
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:37,代码来源:NumberField.java

示例9: AlphaNumericStringComparator

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public AlphaNumericStringComparator(Locale locale) {
    DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
    char localeDecimalSeparator = dfs.getDecimalSeparator();
    // alphaNumChunkPatter initialized here to get correct decimal separator for locale.
    alphaNumChunkPattern = Pattern.compile("(\\d+\\" + localeDecimalSeparator + "\\d+)|(\\d+)|(\\D+)");
}
 
开发者ID:JetBrains,项目名称:teamcity-google-agent,代码行数:7,代码来源:AlphaNumericStringComparator.java

示例10: getDecimalSymbol

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public char getDecimalSymbol(Locale value) {
    DecimalFormatSymbols decimalSystem = new  DecimalFormatSymbols(value);
    return decimalSystem.getDecimalSeparator();
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:5,代码来源:EditBoxTag.java

示例11: replaceWithLocaleDecimalSeparator

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/**
 * Replaces the double decimal separator '.' with the one from the users
 * locale.
 * 
 * @param user
 *            the user to get the locale from
 * @param numberString
 *            the string representing a double value
 * @return the number string with the decimal separator of the users locale
 */
private String replaceWithLocaleDecimalSeparator(PlatformUser user,
        String numberString) {
    Locale locale = LocaleHandler.getLocaleFromString(user.getLocale());
    DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
    char dfsChar = dfs.getDecimalSeparator();
    numberString = numberString.replace('.', dfsChar);
    return numberString;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:BillingResultParser.java


注:本文中的java.text.DecimalFormatSymbols.getDecimalSeparator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。