當前位置: 首頁>>代碼示例>>Java>>正文


Java DecimalFormat.setDecimalFormatSymbols方法代碼示例

本文整理匯總了Java中java.text.DecimalFormat.setDecimalFormatSymbols方法的典型用法代碼示例。如果您正苦於以下問題:Java DecimalFormat.setDecimalFormatSymbols方法的具體用法?Java DecimalFormat.setDecimalFormatSymbols怎麽用?Java DecimalFormat.setDecimalFormatSymbols使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.text.DecimalFormat的用法示例。


在下文中一共展示了DecimalFormat.setDecimalFormatSymbols方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: cluster_simplfication

import java.text.DecimalFormat; //導入方法依賴的package包/類
public static JSONArray cluster_simplfication(JSONArray coords, double tolerance){
	DecimalFormat df = new DecimalFormat("0.0000");
	DecimalFormatSymbols simbolos = new DecimalFormatSymbols();
	simbolos.setDecimalSeparator('.');
	df.setDecimalFormatSymbols(simbolos);
	double pivotx = coords.getDouble(0);
	double pivoty = coords.getDouble(1);
	JSONArray newcoords = new JSONArray();
	newcoords.put(new Float(df.format(pivotx)));
	newcoords.put(new Float(df.format(pivoty)));
	for(int i=2; i<coords.length(); i++){
		if(Math.sqrt(Math.pow((coords.getDouble(i)-pivotx), 2)+Math.pow((coords.getDouble(i+1)-pivoty), 2)) >= tolerance){
			pivotx = coords.getDouble(i);
			pivoty = coords.getDouble(i+1);
			newcoords.put(new Float(df.format(pivotx)));
			newcoords.put(new Float(df.format(pivoty)));
		}
		i++;
	}
	return newcoords;
}
 
開發者ID:acalvoa,項目名稱:EARLGREY,代碼行數:22,代碼來源:GeoAlgorithm.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: test2

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

示例5: getDecimalFormat

import java.text.DecimalFormat; //導入方法依賴的package包/類
/**
 * Procedure creates new dot-separated DecimalFormat
 */
public static DecimalFormat getDecimalFormat(String format)
{
    DecimalFormat df = new DecimalFormat(format);
    DecimalFormatSymbols dfs = new DecimalFormatSymbols();
    dfs.setDecimalSeparator('.');
    dfs.setExponentSeparator("e");
    df.setDecimalFormatSymbols(dfs);
    return df;
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:13,代碼來源:CompatUtils.java

示例6: FormatNumber

import java.text.DecimalFormat; //導入方法依賴的package包/類
/**
 * Helper method used to formats given number into string according to default rules.
 * @param d double to be converted
 * @return string representation of given number
 */
protected String FormatNumber(double d) {
	DecimalFormat nf = new DecimalFormat();
	nf.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.ENGLISH));
	String ret = null;
	// If module of number is greater than 1e-4 or lesser than 1e4 uses ordinary notation
	if (Math.abs(d) > 1e-4 && Math.abs(d) < 1e4 || d == 0) {
		nf.applyPattern("#.####");
		ret = nf.format(d);
	} else {
		nf.applyPattern("0.00E00");
		ret = nf.format(d);
	}
	return ret;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:20,代碼來源:LDStrategyEditor.java

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

示例8: StringFormats

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

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

示例10: getDecimalNumber

import java.text.DecimalFormat; //導入方法依賴的package包/類
/**
 * Returns parsed number.
 * @param number String number representation.
 * @return Parsed number.
 * @throws ParseException Unable to parse given string.
 */
private Number getDecimalNumber(String number) throws ParseException {
	DecimalFormat format = new DecimalFormat();
	DecimalFormatSymbols custom=new DecimalFormatSymbols();
	custom.setDecimalSeparator('.');
	format.setDecimalFormatSymbols(custom);
	return format.parse(number);
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:14,代碼來源:ValueWrapper.java

示例11: toString

import java.text.DecimalFormat; //導入方法依賴的package包/類
/**
 * Returns this distribution's short description
 * @return distribution's short description
 */
@Override
public String toString() {
	DecimalFormat df = new DecimalFormat("#.############");
	df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.ENGLISH));
	Double probability = (Double) parameters[0].getValue();

	//		double revProp = 1-probability.doubleValue();
	return "burst" + "(" + df.format(probability) + "," + parameters[2].getValue() + "," + parameters[4].getValue() + ")";
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:14,代碼來源:Burst.java

示例12: transformToText

import java.text.DecimalFormat; //導入方法依賴的package包/類
public static String transformToText(Transform t){
    DecimalFormat dFormat4 = new DecimalFormat("0.0000");
    DecimalFormat dFormat1 = new DecimalFormat("0.0");
    DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols();
    otherSymbols.setDecimalSeparator('.');
    otherSymbols.setGroupingSeparator(',');
    dFormat4.setDecimalFormatSymbols(otherSymbols);
    dFormat1.setDecimalFormatSymbols(otherSymbols);
    
    StringBuilder sb = new StringBuilder();
    
    Vector3f trans = t.getTranslation();
    sb.append( dFormat4.format(trans.x) ).append(" ");
    sb.append( dFormat4.format(trans.y) ).append(" ");
    sb.append( dFormat4.format(trans.z) ).append(" ");
    
    final Vector3f angles = t.getRotation().toAngles(null).multLocal( M.RAD_TO_DEG );
    sb.append(dFormat1.format( angles.x ) ).append(" ");
    sb.append(dFormat1.format( angles.y ) ).append(" ");
    sb.append(dFormat1.format( angles.z ) ).append(" ");
    
    Vector3f scale = t.getScale();
    sb.append( dFormat4.format(scale.x) ).append(" ");
    sb.append( dFormat4.format(scale.y) ).append(" ");
    sb.append( dFormat4.format(scale.z) );
    
    return sb.toString();
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:29,代碼來源:TransformForm.java

示例13: 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:guodroid,項目名稱:okwallet,代碼行數:17,代碼來源:BtcFormat.java

示例14: print

import java.text.DecimalFormat; //導入方法依賴的package包/類
/** Print the matrix to the output stream.   Line the elements up in
  * columns with a Fortran-like 'Fw.d' style format.
@param output Output stream.
@param w      Column width.
@param d      Number of digits after the decimal.
*/

public void print (PrintWriter output, int w, int d) {
   DecimalFormat format = new DecimalFormat();
   format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
   format.setMinimumIntegerDigits(1);
   format.setMaximumFractionDigits(d);
   format.setMinimumFractionDigits(d);
   format.setGroupingUsed(false);
   print(output,format,w+2);
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:17,代碼來源:Matrix.java

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


注:本文中的java.text.DecimalFormat.setDecimalFormatSymbols方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。