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


Java DecimalFormatSymbols.setGroupingSeparator方法代码示例

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


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

示例1: displayProbabilities

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
private void displayProbabilities() {
    final DecimalFormatSymbols symbols = new DecimalFormatSymbols();
    symbols.setDecimalSeparator('.');
    symbols.setGroupingSeparator(',');
    final DecimalFormat df = new DecimalFormat("", symbols);
    df.setMaximumFractionDigits(1);
    df.setRoundingMode(RoundingMode.HALF_UP);
    df.setMinimumIntegerDigits(1);
    Map<HiddenPower, Double> hiddenPowers = hiddenPowerCalculator.computeHiddenPower(pokemon);
    double badHiddenPower = 0;
    for (final HiddenPower hiddenPower: HiddenPower.values()) {
        double probability = hiddenPowers.get(hiddenPower);
        hiddenPowerLabels.get(hiddenPower.ordinal()).setText(hiddenPower.getName() + ": " + df.format(probability * 100) + "%");
        if (hiddenPower.equals(HiddenPower.WATER) || hiddenPower.equals(HiddenPower.GRASS)) {
            badHiddenPower+= probability;
        }
    }
    feelsBadMan.setVisible(badHiddenPower >= 0.375);
}
 
开发者ID:wartab,项目名称:gen7-iv-calculator,代码行数:20,代码来源:HiddenPowerPresenter.java

示例2: _setUpDecimalSymbolFormatProperties

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
private void _setUpDecimalSymbolFormatProperties(
  DecimalFormatSymbols symbols,
  RequestContext reqCtx,
  Locale locale
  )
{
  if (reqCtx != null)
  {
    char ch = (char) 0;

    if ((ch = reqCtx.getDecimalSeparator()) != (char)0)
      symbols.setDecimalSeparator(ch);

    if ((ch = reqCtx.getNumberGroupingSeparator()) != (char)0)
      symbols.setGroupingSeparator(ch);

  }
  else
  {
    if (_LOG.isWarning())
    {
      _LOG.warning("NULL_REQUESTCONTEXT", locale.toString());
      }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:26,代码来源:NumberConverter.java

示例3: test2

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public static void test2(DecimalFormat df) {
	int number = 155566;
	//默认整数部分三个一组,
	System.out.println(number);//输出格式155,566
	//设置每四个一组
	df.setGroupingSize(4);
	System.out.println(df.format(number));//输出格式为15,5566
	DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance();
	//设置小数点分隔符
	dfs.setDecimalSeparator(';');
	//设置分组分隔符
	dfs.setGroupingSeparator('a');
	df.setDecimalFormatSymbols(dfs);
	System.out.println(df.format(number));//15a5566
	System.out.println(df.format(11.22));//11;22
	//取消分组
	df.setGroupingUsed(false);
	System.out.println(df.format(number));
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:20,代码来源:TestDecimalFormat.java

示例4: main

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public static void main(String[] args) {
    DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.getDefault());
    otherSymbols.setDecimalSeparator(',');
    otherSymbols.setGroupingSeparator('.');
    DecimalFormat df = new DecimalFormat("###0.00", otherSymbols);
    List<Double> prices = Arrays.stream(sc.nextLine().split(", "))
            .map(Double::parseDouble).collect(Collectors.toList());

    UnaryOperator<Double> uOp = (x) -> x * 1.2;

    System.out.println("Prices with VAT:");

    for(Double price : prices){
        System.out.println(df.format(uOp.apply(price)));
    }

}
 
开发者ID:kostovhg,项目名称:SoftUni,代码行数:18,代码来源:p04_AddVAT.java

示例5: printTestInfo

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
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))
        );
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:TestShrinkAuxiliaryData.java

示例6: toString

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public String toString(Object obj){
  DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ROOT);
  symbols.setDecimalSeparator('.');
  symbols.setGroupingSeparator(','); 
  
  DecimalFormat formatDecimal = new DecimalFormat("#0.00", symbols);
  formatDecimal.setRoundingMode(RoundingMode.HALF_UP);
  return formatDecimal.format((Double) obj);
}
 
开发者ID:pablopdomingos,项目名称:nfse,代码行数:10,代码来源:DoubleConversor.java

示例7: parseToCash

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public static String parseToCash( String value) {
    double temp = parseToDouble(value);
    String pattern = "###,###.00";
    DecimalFormatSymbols ds = new DecimalFormatSymbols();
    ds.setDecimalSeparator(',');
    ds.setGroupingSeparator('.');
    DecimalFormat df = new DecimalFormat(pattern,ds);
    df.setGroupingUsed(true);
    return df.format(temp);
}
 
开发者ID:ViniciusSossela,项目名称:meuboleto,代码行数:11,代码来源:InterpretadorCodigoBarras.java

示例8: StrictDecimalFormat

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public StrictDecimalFormat(char decimalSeparator, char groupingSeparator) {
	this();
	DecimalFormatSymbols symbols = getDecimalFormatSymbols();
	symbols.setDecimalSeparator(decimalSeparator);
	symbols.setGroupingSeparator(groupingSeparator);
	setDecimalFormatSymbols(symbols);
	setGroupingUsed(true);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:9,代码来源:StrictDecimalFormat.java

示例9: isDecimal

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public static boolean isDecimal(String input) {
  try {
    DecimalFormatSymbols symbols = new DecimalFormatSymbols();
    symbols.setGroupingSeparator(',');
    symbols.setDecimalSeparator('.');
    String pattern = "#,##0.0#";
    DecimalFormat decimalFormat = new DecimalFormat(pattern, symbols);
    BigDecimal bigDecimal = (BigDecimal) decimalFormat.parse(input);
    return true;
  } catch (Exception ex) {
    return false;
  }
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:14,代码来源:DataTypes.java

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

示例11: convertToString

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/**
 * Returns a nicely formatted representation of a long.
 *
 * @param integer a {@code long}
 * @return a nicely formatted representation of a long
 */
private String convertToString(final long integer) {
    final DecimalFormat format = new DecimalFormat();
    format.setGroupingUsed(integerSettings.getGroupingSeparator() != '\0');

    final DecimalFormatSymbols symbols = format.getDecimalFormatSymbols();
    symbols.setGroupingSeparator(integerSettings.getGroupingSeparator());
    format.setMinimumFractionDigits(0);
    format.setMaximumFractionDigits(0);
    format.setDecimalFormatSymbols(symbols);

    return format.format(integer);
}
 
开发者ID:FWDekker,项目名称:intellij-randomness,代码行数:19,代码来源:IntegerInsertAction.java

示例12: convertToString

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/**
 * Returns a nicely formatted representation of a double.
 *
 * @param decimal a {@code double}
 * @return a nicely formatted representation of a double
 */
private String convertToString(final double decimal) {
    final DecimalFormat format = new DecimalFormat();
    format.setGroupingUsed(decimalSettings.getGroupingSeparator() != '\0');

    final DecimalFormatSymbols symbols = format.getDecimalFormatSymbols();
    symbols.setGroupingSeparator(decimalSettings.getGroupingSeparator());
    symbols.setDecimalSeparator(decimalSettings.getDecimalSeparator());
    format.setMinimumFractionDigits(decimalSettings.getDecimalCount());
    format.setMaximumFractionDigits(decimalSettings.getDecimalCount());
    format.setDecimalFormatSymbols(symbols);

    return format.format(decimal);
}
 
开发者ID:FWDekker,项目名称:intellij-randomness,代码行数:20,代码来源:DecimalInsertAction.java

示例13: StatsCommand

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public StatsCommand(AvaIre avaire) {
    super(avaire);

    DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
    decimalFormatSymbols.setDecimalSeparator('.');
    decimalFormatSymbols.setGroupingSeparator(',');

    number = new DecimalFormat("#,##0", decimalFormatSymbols);
    decimalNumber = new DecimalFormat("#,##0.00", decimalFormatSymbols);
}
 
开发者ID:avaire,项目名称:avaire,代码行数:11,代码来源:StatsCommand.java

示例14: numberFormatter

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
/**
 * @return a number formatter instance which prints numbers in a human
 * readable form, like 9_223_372_036_854_775_807.
 */
public static NumberFormat numberFormatter() {
    DecimalFormat df = new DecimalFormat();
    DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
    dfs.setGroupingSeparator('_');
    dfs.setDecimalSeparator('.');
    df.setDecimalFormatSymbols(dfs);
    return df;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:Helpers.java

示例15: StringFormats

import java.text.DecimalFormatSymbols; //导入方法依赖的package包/类
public StringFormats(){
    formatWith4Decs = new DecimalFormat("0.0000");
    DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols();
    otherSymbols.setDecimalSeparator('.');
    otherSymbols.setGroupingSeparator(',');
    formatWith4Decs.setDecimalFormatSymbols(otherSymbols);
    formatWith2Decs = new DecimalFormat("0.00");
    formatWith2Decs.setDecimalFormatSymbols(otherSymbols);
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:10,代码来源:StringFormats.java


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