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


Java NumberFormat.setGroupingUsed方法代码示例

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


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

示例1: convertToString

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Convert an input Number object into a String.
 *
 * @param value The input value to be converted
 * @return the converted String value.
 * @throws Throwable if an error occurs converting to a String
 */
@Override
protected String convertToString(final Object value) throws Throwable {

    String result = null;
    if (useLocaleFormat && value instanceof Number) {
        final NumberFormat format = getFormat();
        format.setGroupingUsed(false);
        result = format.format(value);
        if (log().isDebugEnabled()) {
            log().debug("    Converted  to String using format '" + result + "'");
        }

    } else {
        result = value.toString();
        if (log().isDebugEnabled()) {
            log().debug("    Converted  to String using toString() '" + result + "'");
        }
    }
    return result;

}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:29,代码来源:NumberConverter.java

示例2: test

import java.text.NumberFormat; //导入方法依赖的package包/类
private void test(double val) throws Exception {
    // Should behave exactly the same as standard number format
    // with no extra trailing zeros, six max trailing zeros.
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMinimumFractionDigits(0);
    nf.setMaximumFractionDigits(6);
    nf.setGroupingUsed(false);

    String expected = nf.format(val);

    StringBuilder sb = new StringBuilder();

    DoubleFormat.format(sb, val);

    assertEquals(expected, sb.toString());
}
 
开发者ID:awslabs,项目名称:swage,代码行数:17,代码来源:DoubleFormatTest.java

示例3: setNumberOfAgents

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Sets the number of agents.
 * @param noAgents the new number of agents
 */
public void setNumberOfAgents(Integer noAgents) {
	
	String displayText = null;
	
	NumberFormat nf = NumberFormat.getInstance(); 
	nf.setMinimumIntegerDigits(5);  
	nf.setMaximumIntegerDigits(5); 
	nf.setGroupingUsed(false);
	
	if (noAgents==null) {
		displayText = " " + nf.format(0) + " " + Language.translate("Agenten") + " ";
	} else {
		displayText = " " + nf.format(noAgents) + " " + Language.translate("Agenten") + " ";
	}
	jLabelAgentCount.setText(displayText);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:21,代码来源:SystemLoadPanel.java

示例4: getUniqueName

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Helper function to generate a name that is unique for the task.
 *
 * <p>The generated name can be used to create custom files from within the
 * different tasks for the job, the names for different tasks will not collide
 * with each other.</p>
 *
 * <p>The given name is postfixed with the task type, 'm' for maps, 'r' for
 * reduces and the task partition number. For example, give a name 'test'
 * running on the first map o the job the generated name will be
 * 'test-m-00000'.</p>
 *
 * @param conf the configuration for the job.
 * @param name the name to make unique.
 * @return a unique name accross all tasks of the job.
 */
public static String getUniqueName(JobConf conf, String name) {
  int partition = conf.getInt(JobContext.TASK_PARTITION, -1);
  if (partition == -1) {
    throw new IllegalArgumentException(
      "This method can only be called from within a Job");
  }

  String taskType = conf.getBoolean(JobContext.TASK_ISMAP,
      JobContext.DEFAULT_TASK_ISMAP) ? "m" : "r";

  NumberFormat numberFormat = NumberFormat.getInstance();
  numberFormat.setMinimumIntegerDigits(5);
  numberFormat.setGroupingUsed(false);

  return name + "-" + taskType + "-" + numberFormat.format(partition);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:FileOutputFormat.java

示例5: prettyPrint

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Return a string with a table describing all tasks performed.
 * For custom reporting, call getTaskInfo() and use the task info directly.
 */
public String prettyPrint() {
    StringBuilder sb = new StringBuilder(shortSummary());
    sb.append('\n');
    if (!this.keepTaskList) {
        sb.append("No task info kept");
    } else {
        sb.append("-----------------------------------------\n");
        sb.append("ms     %     Task name\n");
        sb.append("-----------------------------------------\n");
        NumberFormat nf = NumberFormat.getNumberInstance(Locale.ROOT);
        nf.setMinimumIntegerDigits(5);
        nf.setGroupingUsed(false);
        NumberFormat pf = NumberFormat.getPercentInstance(Locale.ROOT);
        pf.setMinimumIntegerDigits(3);
        pf.setGroupingUsed(false);
        for (TaskInfo task : taskInfo()) {
            sb.append(nf.format(task.getTime().millis())).append("  ");
            sb.append(pf.format(task.getTime().secondsFrac() / totalTime().secondsFrac())).append("  ");
            sb.append(task.getTaskName()).append("\n");
        }
    }
    return sb.toString();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:StopWatch.java

示例6: toString

import java.text.NumberFormat; //导入方法依赖的package包/类
@Override
public String toString() {
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(4);
    nf.setGroupingUsed(false);

    StringBuilder sb = new StringBuilder();

    sb.append("Date: ").append(date.format(formatter)).append(", ");
    sb.append("Total NAV: ").append(nf.format(totalNav)).append(", ");
    sb.append("Share price: ").append(nf.format(sharePrice)).append(", ");
    sb.append("Total shares: ").append(nf.format(getTotalShares()));

    return sb.toString();
}
 
开发者ID:ivandavidov,项目名称:baud,代码行数:17,代码来源:BaudEntryDay.java

示例7: prettyPrint

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Return a string with a table describing all tasks performed. For custom
 * reporting, call getTaskInfo() and use the task info directly.
 */
public String prettyPrint() {
	StringBuilder sb = new StringBuilder(shortSummary());
	sb.append('\n');
	if (!this.keepTaskList) {
		sb.append("No task info kept");
	} else {
		sb.append("-----------------------------------------\n");
		sb.append("ms     %     Task name\n");
		sb.append("-----------------------------------------\n");
		NumberFormat nf = NumberFormat.getNumberInstance();
		nf.setMinimumIntegerDigits(5);
		nf.setGroupingUsed(false);
		NumberFormat pf = NumberFormat.getPercentInstance();
		pf.setMinimumIntegerDigits(3);
		pf.setGroupingUsed(false);
		for (TaskInfo task : getTaskInfo()) {
			sb.append(nf.format(task.getTimeMillis())).append("  ");
			sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append("  ");
			sb.append(task.getTaskName()).append("\n");
		}
	}
	return sb.toString();
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:28,代码来源:StopWatch.java

示例8: initialValue

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

示例9: initialValue

import java.text.NumberFormat; //导入方法依赖的package包/类
@Override
public NumberFormat initialValue() {
  NumberFormat fmt = NumberFormat.getInstance();
  fmt.setGroupingUsed(false);
  fmt.setMinimumIntegerDigits(6);
  return fmt;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:ApplicationAttemptId.java

示例10: formatNumber

import java.text.NumberFormat; //导入方法依赖的package包/类
public static String formatNumber(double number, int decimal, boolean grouping) {
	if (number >= 0) {
		NumberFormat n = NumberFormat.getNumberInstance();
		n.setGroupingUsed(grouping);
		if (decimal > 0) {
			n.setMinimumFractionDigits(decimal);
			n.setMaximumFractionDigits(decimal);
		}
		return n.format(number);
	} else {
		return "";
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:14,代码来源:Formatter.java

示例11: setNumberOfContainer

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Sets the number of container.
 * @param noContainer the new number of container
 */
public void setNumberOfContainer(Integer noContainer) {
	
	NumberFormat nf = NumberFormat.getInstance(); 
	nf.setMinimumIntegerDigits(3);  
	nf.setMaximumIntegerDigits(3); 
	nf.setGroupingUsed(false);
	String displaText = " " + nf.format(noContainer) + " " + Language.translate("Container") + " ";
	jLabelContainerCount.setText(displaText);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:14,代码来源:SystemLoadPanel.java

示例12: offset2FileName

import java.text.NumberFormat; //导入方法依赖的package包/类
public static String offset2FileName(final long offset) {
    final NumberFormat nf = NumberFormat.getInstance();
    nf.setMinimumIntegerDigits(20);
    nf.setMaximumFractionDigits(0);
    nf.setGroupingUsed(false);
    return nf.format(offset);
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:8,代码来源:UtilAll.java

示例13: getFormatter

import java.text.NumberFormat; //导入方法依赖的package包/类
private static NumberFormat getFormatter(Locale locale, int minimumFractionDigits, int maximumFractionDigits) {
    NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
    numberFormat.setMinimumFractionDigits(minimumFractionDigits);
    numberFormat.setMaximumFractionDigits(maximumFractionDigits);
    numberFormat.setGroupingUsed(false);
    return numberFormat;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:8,代码来源:Security.java

示例14: getNumberFormat

import java.text.NumberFormat; //导入方法依赖的package包/类
@Override
public NumberFormat getNumberFormat(Class<? extends Number> numberType, int decimalPositions,
		boolean disableGrouping) {

	int decimals = decimalPositions;
	if (decimals < 0) {
		// use default, if any
		if (getLocalization() != null) {
			decimals = getLocalization().getDefaultDecimalPositions().orElse(-1);
		}
	}

	NumberFormat format = null;

	if (TypeUtils.isDecimalNumber(numberType)) {
		format = NumberFormat.getInstance(checkLocalized());
		if (decimals > -1) {
			format.setMinimumFractionDigits(decimals);
			format.setMaximumFractionDigits(decimals);
		}
	} else {
		format = NumberFormat.getIntegerInstance(checkLocalized());
	}

	if (disableGrouping) {
		format.setGroupingUsed(false);
	}
	return format;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:30,代码来源:DefaultLocalizationContext.java

示例15: getNf

import java.text.NumberFormat; //导入方法依赖的package包/类
private static NumberFormat getNf(Locale locale) {
	NumberFormat nf = null;
	if (locale == null) {
		nf = NumberFormat.getNumberInstance();
	} else {
		nf = NumberFormat.getNumberInstance(locale);
	}
	nf.setGroupingUsed(false);
	return nf;
}
 
开发者ID:youngMen1,项目名称:JAVA-,代码行数:11,代码来源:TypeParseUtil.java


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