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


Java DecimalFormat.getDecimalFormatSymbols方法代码示例

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


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

示例1: initialValue

import java.text.DecimalFormat; //导入方法依赖的package包/类
@Override
protected NumberFormat initialValue() {

    // Always create the formatter for the US locale in order to avoid this bug:
    // https://github.com/indeedeng/java-dogstatsd-client/issues/3
    final NumberFormat numberFormatter = NumberFormat.getInstance(Locale.US);
    numberFormatter.setGroupingUsed(false);
    numberFormatter.setMaximumFractionDigits(6);

    // we need to specify a value for Double.NaN that is recognized by dogStatsD
    if (numberFormatter instanceof DecimalFormat) { // better safe than a runtime error
        final DecimalFormat decimalFormat = (DecimalFormat) numberFormatter;
        final DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols();
        symbols.setNaN("NaN");
        decimalFormat.setDecimalFormatSymbols(symbols);
    }

    return numberFormatter;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:20,代码来源:DoubleFormat.java

示例2: _setCurrencyFormattingProperties

import java.text.DecimalFormat; //导入方法依赖的package包/类
private void _setCurrencyFormattingProperties(
  RequestContext context,
  NumberFormat numberFormatter
 )
{
  // Useless if... should be instanceof DecimalFormat
  // Potential ClassCastException before the change
  //if (numberFormatter instanceof NumberFormat)
  if (numberFormatter instanceof DecimalFormat)
  {
    DecimalFormat dfmt = (DecimalFormat)numberFormatter;
    DecimalFormatSymbols symbols = dfmt.getDecimalFormatSymbols();
    _setCurrencyInformation(context, symbols);
    dfmt.setDecimalFormatSymbols(symbols);
  }
  else
  {  //string cat at compile time.
    _LOG.warning("NUMBER_NOT_DECIMALFORMAT_IGNORE_CURRENCY");
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:21,代码来源:NumberConverter.java

示例3: printTestInfo

import java.text.DecimalFormat; //导入方法依赖的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

示例4: toString

import java.text.DecimalFormat; //导入方法依赖的package包/类
@Override
public String toString() {
    DecimalFormat format = new DecimalFormat();
    format.setMinimumFractionDigits(precision);
    format.setMaximumFractionDigits(precision);
    DecimalFormatSymbols dfs = format.getDecimalFormatSymbols();
    dfs.setDecimalSeparator(DECIMAL_SEPARATOR);
    format.setDecimalFormatSymbols(dfs);
    format.setGroupingUsed(false);
    return format.format(magnitude) + ((unit == null || unit.isEmpty()) ? "" : "," + getUnit());
}
 
开发者ID:gdl-lang,项目名称:gdl2,代码行数:12,代码来源:DvQuantity.java

示例5: setSymbolAndCode

import java.text.DecimalFormat; //导入方法依赖的package包/类
/** Set the currency symbol and international code of the underlying {@link
  * java.text.NumberFormat} object to the values of the last two arguments, respectively.
  * This method is invoked in the process of parsing, not formatting.
  *
  * Only invoke this from code synchronized on value of the first argument, and don't
  * forget to put the symbols back otherwise equals(), hashCode() and immutability will
  * break.  */
private static DecimalFormatSymbols setSymbolAndCode(DecimalFormat numberFormat, String symbol, String code) {
    checkState(Thread.holdsLock(numberFormat));
    DecimalFormatSymbols fs = numberFormat.getDecimalFormatSymbols();
    DecimalFormatSymbols ante = (DecimalFormatSymbols)fs.clone();
    fs.setInternationalCurrencySymbol(code);
    fs.setCurrencySymbol(symbol);
    numberFormat.setDecimalFormatSymbols(fs);
    return ante;
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:17,代码来源:BtcFormat.java

示例6: convertToString

import java.text.DecimalFormat; //导入方法依赖的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

示例7: convertToString

import java.text.DecimalFormat; //导入方法依赖的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

示例8: numberFormatter

import java.text.DecimalFormat; //导入方法依赖的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

示例9: main

import java.text.DecimalFormat; //导入方法依赖的package包/类
public static void main(String[] argv) throws Exception {
    DecimalFormat df = (DecimalFormat)NumberFormat.getInstance(Locale.JAPAN);
    DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
    if (dfs.getPatternSeparator() != ';') {
        throw new Exception("DecimalFormatSymbols.getPatternSeparator doesn't return ';' in ja locale");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TestgetPatternSeparator_ja.java

示例10: _getNumberFormat

import java.text.DecimalFormat; //导入方法依赖的package包/类
private NumberFormat _getNumberFormat(
  String pattern,
  String type,
  Locale locale,
  RequestContext reqCtx
  )
{
  NumberFormat nfmt;

  int formatType = _getType(pattern, type);

  nfmt = _getCachedNumberFormat(pattern, type, locale);

  if (nfmt == null)
  {
    nfmt = _getNumberFormatter(formatType, pattern, locale);

   _cacheNumberFormat(nfmt,pattern, type, locale);
  }

  if (nfmt instanceof DecimalFormat)
  {
    DecimalFormat dfmt = (DecimalFormat)nfmt;

    // what we get here is a shallow copy. cloned DFS
    DecimalFormatSymbols dfSymbols = dfmt.getDecimalFormatSymbols();

    _setUpDecimalSymbolFormatProperties(dfSymbols, reqCtx, locale);

    //since we get a shallow copy - setting it again after modification.
    ((DecimalFormat) nfmt).setDecimalFormatSymbols(dfSymbols);
  }
  else
  {
    if(_LOG.isWarning())
    {
      _LOG.warning("Failed to get hold of DecimalFormat for type: +" + type + "\n" +
                   "decimal separator,"         +
                   "number grouping separator," +
                   "currency code"              +
                   "will be defaulted based on locale " + locale.toString());
   }
  }
  return nfmt;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:46,代码来源:NumberConverter.java

示例11: prefixUnitsIndicator

import java.text.DecimalFormat; //导入方法依赖的package包/类
/**
 * Set both the currency symbol and code of the underlying, mutable NumberFormat object
 * according to the given denominational units scale factor.  This is for formatting, not parsing.
 *
 * <p>Set back to zero when you're done formatting otherwise immutability, equals() and
 * hashCode() will break!
 *
 * @param scale Number of places the decimal point will be shifted when formatting
 *              a quantity of satoshis.
 * @return The DecimalFormatSymbols before changing
 */
protected static void prefixUnitsIndicator(DecimalFormat numberFormat, int scale) {
    checkState(Thread.holdsLock(numberFormat)); // make sure caller intends to reset before changing
    DecimalFormatSymbols fs = numberFormat.getDecimalFormatSymbols();
    setSymbolAndCode(numberFormat,
        prefixSymbol(fs.getCurrencySymbol(), scale), prefixCode(fs.getInternationalCurrencySymbol(), scale)
    );
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:19,代码来源:BtcFormat.java

示例12: prefixUnitsIndicator

import java.text.DecimalFormat; //导入方法依赖的package包/类
/**
 * Set both the currency symbol and code of the underlying, mutable NumberFormat object
 * according to the given denominational units scale factor.  This is for formatting, not parsing.
 *
 * <p>Set back to zero when you're done formatting otherwise immutability, equals() and
 * hashCode() will break!
 *
 * @param scale Number of places the decimal point will be shifted when formatting
 *              a quantity of satoshis.
 */
protected static void prefixUnitsIndicator(DecimalFormat numberFormat, int scale) {
    checkState(Thread.holdsLock(numberFormat)); // make sure caller intends to reset before changing
    DecimalFormatSymbols fs = numberFormat.getDecimalFormatSymbols();
    setSymbolAndCode(numberFormat,
        prefixSymbol(fs.getCurrencySymbol(), scale), prefixCode(fs.getInternationalCurrencySymbol(), scale)
    );
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:18,代码来源:BtcFormat.java


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