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


Java DecimalFormatSymbols.getGroupingSeparator方法代码示例

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


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

示例4: initSettings

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/***
 * If user does not provide a valid locale it throws IllegalArgumentException.
 *
 * If throws an IllegalArgumentException the locale sets to default locale
 */
private void initSettings() {
    boolean success = false;
    while (!success) {
        try {
            fractionDigit = Currency.getInstance(locale).getDefaultFractionDigits();

            DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale);
            if (mGroupDivider > 0)
                symbols.setGroupingSeparator(mGroupDivider);
            groupDivider = symbols.getGroupingSeparator();

            if (mMonetaryDivider > 0)
                symbols.setMonetaryDecimalSeparator(mMonetaryDivider);
            monetaryDivider = symbols.getMonetaryDecimalSeparator();

            currencySymbol = symbols.getCurrencySymbol();

            DecimalFormat df = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale);
            numberFormat = new DecimalFormat(df.toPattern(), symbols);

            success = true;
        } catch (IllegalArgumentException e) {
            Log.e(getClass().getCanonicalName(), e.getMessage());
            locale = getDefaultLocale();
        }
    }
}
 
开发者ID:FranciscoJavierPRamos,项目名称:Android-FilterView,代码行数:33,代码来源:CurrencyEditText.java

示例5: 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


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