當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。