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


Java NumberFormat.getNumberInstance方法代码示例

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


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

示例1: write

import java.text.NumberFormat; //导入方法依赖的package包/类
public void write(PrintWriter printer, TimeSeries series) {

        Locale locale  = new Locale("en", "US");
        DecimalFormat formatter = (DecimalFormat)NumberFormat.getNumberInstance(locale);
        formatter.applyPattern("0.0000######");

        printer.print(String.format(header, series.getProperty("sensorid"), series.getLocation(), series.getProperty("position"), series.getSource(), series.getQuantityId(), series.getUnitId(),  series.getProperty("use") ));

        final double times[] = series.getTimesRef();
        final double values[] = series.getValuesRef();
        //TODO: detect order on read and use this order
        printer.println("datetime;value");
        String dateString;
        for (int i = 0; i < times.length; i++) {
            dateString = TimeUtils.mjdToString( times[i],this.datePattern);
            printer.println( dateString + this.delimiter + formatter.format(values[i]) );
        }
        printer.flush();
    }
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:20,代码来源:CsvTimeSeriesFormatter.java

示例2: 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:baidu,项目名称:Elasticsearch,代码行数:28,代码来源:StopWatch.java

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

示例4: updateGridStatistics

import java.text.NumberFormat; //导入方法依赖的package包/类
private void updateGridStatistics() {
	NumberFormat intFormat = NumberFormat.getIntegerInstance();

	String infoDisplay = "Area (L, O, T) km\u00B2 :\t" +
		intFormat.format(landArea) + "\t" +
		intFormat.format(oceanArea) + "\t" +
		intFormat.format(landArea + oceanArea) + "\n";

	NumberFormat oneDec = NumberFormat.getNumberInstance();
	oneDec.setMaximumFractionDigits(1);

	String landMeanZstr = Float.isNaN(landMeanZ) ? "NaN" : oneDec.format(landMeanZ);
	String oceanMeanZstr = Float.isNaN(oceanMeanZ) ? "NaN" : oneDec.format(oceanMeanZ);
	String totalMeanZstr = Float.isNaN(totalMeanZ) ? "NaN" : oneDec.format(totalMeanZ);

	infoDisplay += "Mean Elev (L, O, T) m :\t" +
		landMeanZstr + "\t" +
		oceanMeanZstr + "\t" +
		totalMeanZstr + "\n";

	String landSlopeMeanStr = Float.isNaN(landSlopeMean) ? "NaN" : oneDec.format(landSlopeMean);
	String oceanSlopeMeanStr = Float.isNaN(oceanSlopeMean) ? "NaN" : oneDec.format(oceanSlopeMean);
	String totalSlopeMeanStr = Float.isNaN(totalSlopeMean) ? "NaN" : oneDec.format(totalSlopeMean);

	infoDisplay += "Mean Slope (L, O, T) \u00B0 :\t" +
		landSlopeMeanStr + "\t" +
		oceanSlopeMeanStr + "\t" +
		totalSlopeMeanStr;

	gridStatistics.setText(infoDisplay);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:32,代码来源:RenderingTools.java

示例5: 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:tb544731152,项目名称:iBase4J,代码行数:11,代码来源:TypeParseUtil.java

示例6: setFileSizeSave

import java.text.NumberFormat; //导入方法依赖的package包/类
public void setFileSizeSave(long size){
	NumberFormat nf=NumberFormat.getNumberInstance() ; 
	nf.setMaximumFractionDigits(2);
	if(size<1024){
		fileSize =nf.format(size) +"B";
	}else if(size<1024*1024){
		this.fileSize =nf.format(size/1024.0) + "KB";
	}else if(size<1024*1024*1024){
		this.fileSize = nf.format(size/1024.0 * 1024) + "MB";
	}else if(size<1024*1024*1024*1024){
		this.fileSize = nf.format(size/1024.0 * 1024 * 1024) + "GB";
	}	
}
 
开发者ID:ranji1221,项目名称:lemcloud,代码行数:14,代码来源:BackupDatabaseInfo.java

示例7: MonthDateFormat

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Creates a new formatter.
 * 
 * @param zone  the time zone used to extract the month and year from dates
 *              passed to this formatter (<code>null</code> not permitted).
 * @param locale  the locale used to determine the month names 
 *                (<code>null</code> not permitted).
 * @param chars  the maximum number of characters to use from the month 
 *               names, or zero to indicate that the entire month name 
 *               should be used.
 * @param showYear  an array of flags that control whether or not the
 *                  year is displayed for a particular month.
 * @param yearFormatter  the year formatter.
 */
public MonthDateFormat(TimeZone zone, Locale locale, int chars, 
                       boolean[] showYear, DateFormat yearFormatter) {
    if (locale == null) {
        throw new IllegalArgumentException("Null 'locale' argument.");
    }
    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    String[] monthsFromLocale = dfs.getMonths();
    this.months = new String[12];
    for (int i = 0; i < 12; i++) {
        if (chars > 0) {
            months[i] = monthsFromLocale[i].substring(0, 
                    Math.min(chars, monthsFromLocale[i].length()));
        }
        else {
            months[i] = monthsFromLocale[i];
        }
    }
    this.calendar = new GregorianCalendar(zone);
    this.showYear = showYear;
    this.yearFormatter = yearFormatter; 
    
    // the following is never used, but it seems that DateFormat requires
    // it to be non-null.  It isn't well covered in the spec, refer to 
    // bug parade 5061189 for more info.
    this.numberFormat = NumberFormat.getNumberInstance();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:41,代码来源:MonthDateFormat.java

示例8: getFileColumnData

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Get the standard file column header information.
 * This default implementation is intended only for standard mode.
 * displayMode is specified in FormattedDisk.
 */
public List<String> getFileColumnData(int displayMode) {
	NumberFormat numberFormat = NumberFormat.getNumberInstance();
	List<String> list = new ArrayList<>();
	switch (displayMode) {
		case FormattedDisk.FILE_DISPLAY_NATIVE:
			list.add(isLocked() ? "*" : " "); //$NON-NLS-1$ //$NON-NLS-2$
			list.add(getFiletype());
			numberFormat.setMinimumIntegerDigits(3);
			list.add(numberFormat.format(getSectorsUsed()));
			list.add(getFilename());
			break;
		case FormattedDisk.FILE_DISPLAY_DETAIL:
			list.add(isLocked() ? "*" : " "); //$NON-NLS-1$ //$NON-NLS-2$
			list.add(getFiletype());
			list.add(getFilename());
			list.add(numberFormat.format(getSize()));
			numberFormat.setMinimumIntegerDigits(3);
			list.add(numberFormat.format(getSectorsUsed()));
			list.add(isDeleted() ? textBundle.get("Deleted") : "");  //$NON-NLS-1$//$NON-NLS-2$
			list.add("T" + getTrack() + " S" + getSector()); //$NON-NLS-1$ //$NON-NLS-2$
			break;
		default:	// FILE_DISPLAY_STANDARD
			list.add(getFilename());
			list.add(getFiletype());
			list.add(numberFormat.format(getSize()));
			list.add(isLocked() ? textBundle.get("Locked") : "");  //$NON-NLS-1$//$NON-NLS-2$
			break;
	}
	return list;
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:36,代码来源:GutenbergFileEntry.java

示例9: parseValue

import java.text.NumberFormat; //导入方法依赖的package包/类
@Override
protected Double parseValue(String arg, Locale locale)
        throws IllegalOptionValueException {
  try {
    NumberFormat format = NumberFormat.getNumberInstance(locale);
    Number num = (Number) format.parse(arg);
    return new Double(num.doubleValue());
  } catch (ParseException e) {
    throw new IllegalOptionValueException(this, arg);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:12,代码来源:CmdLineParser.java

示例10: StandardXYToolTipGenerator

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Creates a tool tip generator using default number formatters.
 */
public StandardXYToolTipGenerator() {
    this(
        DEFAULT_TOOL_TIP_FORMAT,
        NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance()
    );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:StandardXYToolTipGenerator.java

示例11: 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:max6cn,项目名称:jmt,代码行数:14,代码来源:Formatter.java

示例12: toCsvString

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

    StringBuilder sb = new StringBuilder();

    sb.append(date.format(formatter)).append(",");
    sb.append(nf.format(totalNav)).append(",");
    sb.append(nf.format(sharePrice)).append(",");
    sb.append(nf.format(getTotalShares()));

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

示例13: StandardXYItemLabelGenerator

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Creates an item label generator using default number formatters.
 */
public StandardXYItemLabelGenerator() {
    this(DEFAULT_ITEM_LABEL_FORMAT, NumberFormat.getNumberInstance(), 
            NumberFormat.getNumberInstance());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:8,代码来源:StandardXYItemLabelGenerator.java

示例14: BubbleXYItemLabelGenerator

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Creates a new tool tip generator using default number formatters for the
 * x, y and z-values.
 */
public BubbleXYItemLabelGenerator() {
    this(DEFAULT_FORMAT_STRING, NumberFormat.getNumberInstance(),
            NumberFormat.getNumberInstance(), 
            NumberFormat.getNumberInstance());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:BubbleXYItemLabelGenerator.java

示例15: AbstractXYItemLabelGenerator

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Creates an item label generator using default number formatters.
 */
protected AbstractXYItemLabelGenerator() {
    this("{2}", NumberFormat.getNumberInstance(), 
            NumberFormat.getNumberInstance());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:8,代码来源:AbstractXYItemLabelGenerator.java


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