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


Java NumberFormat类代码示例

本文整理汇总了Java中com.google.gwt.i18n.client.NumberFormat的典型用法代码示例。如果您正苦于以下问题:Java NumberFormat类的具体用法?Java NumberFormat怎么用?Java NumberFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getDatasetPanelValue

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
/**
 * Get dataset panel show values .
 * 
 * @param dataset
 * @param isUpdate
 * @return  Data panel show value array
 */
public static String[] getDatasetPanelValue(final Dataset dataset, boolean isUpdate) {
	String[] values = new String[7];
	Date dateNow = new Date();
	DateTimeFormat dateFormat = DateTimeFormat
			.getFormat("yyyy-MM-dd KK:mm:ss a");
	values[4] = dateFormat.format(dateNow);
	double version = 0;
	if ((!dataset.getVersion().contains("n"))&&isUpdate){
		version = Double.parseDouble(dataset.getVersion()) + 0.1;
	}else version = Double.parseDouble(dataset.getVersion());     
	values[3] = NumberFormat.
			getFormat("#0.0").format(version);

	values[1] = null;
	String TypeString = dataset.getContenttype();
	if ("General".equals(TypeString)) values[2] = "General/TSV/CSV";
	if ("TSV".equals(TypeString)) values[2] = "TSV/General/TSV";
	if ("CSV".equals(TypeString)) values[2] = "CSV/General/TSV";
	else values[2] = "General/TSV/CSV";
	values[0] = dataset.getName();
	values[5] = AppController.email;
	values[6] = dataset.getDescription();
	return values;
}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:32,代码来源:DBController.java

示例2: timeDiff

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
public static String timeDiff(Date date1, Date date2) {
	if( date1 == null || date2 == null ) return "";
	long nh = 1000 * 60 * 60;
	long nm = 1000 * 60;
	long ns = 1000;
	try {
		long diff = date2.getTime() - date1.getTime();

		// gap of hour
		long hour = diff / nh;
		// gap of min
		long min = diff % nh / nm;
		// gap of sec
		long sec = diff % nh % nm / ns;
		String res = NumberFormat.getFormat("#00").format(hour) + ":"
				+ NumberFormat.getFormat("#00").format(min) + ":"
				+ NumberFormat.getFormat("#00").format(sec);
		return res;
	} catch (IllegalArgumentException ex) {
		return null;
	}
}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:23,代码来源:TimeUtils.java

示例3: getNumberFormat

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
private NumberFormat getNumberFormat() {
    NumberFormat nf;
    if (sciNote) {
        nf= NumberFormat.getScientificFormat();
    }
    else {
        StringBuffer sb= new StringBuffer(9);
        if (precision==0) {
            nf= NumberFormat.getFormat("#");
        }
        else {
            sb.append("#.");
            for(int i= 0; (i<precision); i++) sb.append("#");
            nf= NumberFormat.getFormat(sb.toString());
        }
    }
    return nf;
}
 
开发者ID:lsst,项目名称:firefly,代码行数:19,代码来源:DecimalFieldDef.java

示例4: formatBytes

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
private static String formatBytes(long bytes, boolean abs) {
  bytes = abs ? Math.abs(bytes) : bytes;

  if (bytes == 0) {
    return abs ? "0 B" : "+/- 0 B";
  }

  if (Math.abs(bytes) < 1024) {
    return (bytes > 0 && !abs ? "+" : "") + bytes + " B";
  }

  int exp = (int) (Math.log(Math.abs(bytes)) / Math.log(1024));
  return (bytes > 0 && !abs ? "+" : "")
      + NumberFormat.getFormat("#.0").format(bytes / Math.pow(1024, exp))
      + " "
      + "KMGTPE".charAt(exp - 1)
      + "iB";
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:FormatUtil.java

示例5: createNumberField

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
/**
 * Create a number field to represent a default flexible element.
 *
 * @param allowBlank If the field allow blank value.
 * @return The number field.
 */
protected NumberField createNumberField(final boolean allowBlank) {

  final NumberField numberField = new NumberField();
  numberField.setAllowDecimals(true);
  numberField.setAllowNegative(false);
  numberField.setAllowBlank(allowBlank);
  preferredWidth = FlexibleElementDTO.NUMBER_FIELD_WIDTH;

  // Decimal format
  final NumberFormat format = NumberFormat.getDecimalFormat();
  numberField.setFormat(format);

  // Sets the min value.
  final Number minValue = 0.0;
  numberField.setMinValue(minValue);

  return numberField;
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:25,代码来源:AbstractDefaultFlexibleElementDTO.java

示例6: setValue

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
public void setValue(T value) {
	this.value = value;
	double val = 0;
	if (value == null) {
		val = this.min;
	} else {
		val = value.doubleValue();
	}
	if (val > this.max) {
		val = this.max;
	} else if (val < this.min) {
		val = this.min;
	}

	this.progressBarElement.setAttribute(OutputProgressBar.ATT_ARIA_VALUE, value + "");
	double percent = 100 * (val - this.min) / (this.max - this.min);
	this.progressBarElement.getStyle().setProperty("width", percent, Unit.PCT);

	NumberFormat formatter = NumberFormat.getFormat("#.##");

	String stringToDisplay = this.format;
	stringToDisplay = RegExp.compile("\\{0\\}").replace(stringToDisplay, formatter.format(val));
	stringToDisplay = RegExp.compile("\\{1\\}").replace(stringToDisplay, formatter.format(percent));
	stringToDisplay = RegExp.compile("\\{2\\}").replace(stringToDisplay, formatter.format(this.min));
	stringToDisplay = RegExp.compile("\\{3\\}").replace(stringToDisplay, formatter.format(this.max));

	this.progressBarElement.removeAllChildren();
	if (this.displayValue) {
		this.progressBarElement.setInnerText(stringToDisplay);
	} else {
		SpanElement reader = Document.get().createSpanElement();
		reader.setInnerText(stringToDisplay);
		reader.addClassName("sr-only");
		this.progressBarElement.appendChild(reader);
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:37,代码来源:OutputProgressBar.java

示例7: formatNumberToFractial

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
@Override
public String formatNumberToFractial(Number val, int fractial) {
    if (val == null)
        return "";

    if (fractial < 1)
        return formatNumberGroupThousands(val);

    String format = "#,##0.";

    for (int i = 0; i < fractial; i++) {
        format += "0";
    }

    return NumberFormat.getFormat(format).format(val).replace(",", "&nbsp;").replace('.', ',');
}
 
开发者ID:inepex,项目名称:ineform,代码行数:17,代码来源:NumberUtilCln.java

示例8: csvFormatNumberToFractial

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
@Override
public String csvFormatNumberToFractial(Double val, int fractial) {
    if (val == null)
        return "";

    if (fractial < 1)
        return formatNumberGroupThousands(val).replace("&nbsp;", "");

    String format = "0.";

    for (int i = 0; i < fractial; i++) {
        format += "0";
    }

    return NumberFormat.getFormat(format).format(val).replace('.', ',');
}
 
开发者ID:inepex,项目名称:ineform,代码行数:17,代码来源:NumberUtilCln.java

示例9: setHighScore

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
public void setHighScore(int scoreIndex, String playerName, int highScore) {
        int maxLength = SCORE_PAGE.texttspan5634().length();
        NumberFormat decimalFormat = NumberFormat.getDecimalFormat();
        String formattedScore = decimalFormat.format(highScore);
        playerName += "                                      ";
        String labelText = playerName.substring(0, maxLength - 1 - formattedScore.length()).concat(" ").concat(formattedScore);
//        labelText = labelText.replace(" ", "&nbsp;");
//        String.format("%1$" + n + "s", playerName);
        switch (scoreIndex) {
            case 0:
                scorePageBuilder.setLabel(SvgTextElements.tspan4348, labelText);
                break;
            case 1:
                scorePageBuilder.setLabel(SvgTextElements.tspan5630, labelText);
                break;
            case 2:
                scorePageBuilder.setLabel(SvgTextElements.tspan4379, labelText);
                break;
            case 3:
                scorePageBuilder.setLabel(SvgTextElements.tspan5632, labelText);
                break;
            case 4:
                scorePageBuilder.setLabel(SvgTextElements.tspan5634, labelText);
                break;
        }
    }
 
开发者ID:languageininteraction,项目名称:LanguageMemoryApp,代码行数:27,代码来源:ScorePageView.java

示例10: formatUnits

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
/**
 * Convert distance (in CRS units) to human readable format (including unit indicator).
 * 
 * @param units unit
 * @return human readable string in unit type
 */
String formatUnits(int units) {
	switch (unitType) {
		case ENGLISH:
			return NumberFormat.getDecimalFormat().format(units) + (widthInUnitsIsMiles ? " mi" : " yd");
		case ENGLISH_FOOT:
			return NumberFormat.getDecimalFormat().format(units) + (widthInUnitsIsMiles ? " mi" : " ft");
		case METRIC:
			if (units < 10000) {
				return NumberFormat.getDecimalFormat().format(units) + " m";
			} else {
				return NumberFormat.getDecimalFormat().format((double) units / 1000) + " km";
			}

		case CRS:
			return NumberFormat.getDecimalFormat().format(units) + " u";

		default:
			throw new IllegalStateException("Unknown unit type " + unitType);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt,代码行数:27,代码来源:ScaleBar.java

示例11: formatUnits

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
/**
 * format to human readable string converting to unit type.
 *
 * @param units
 * @return
 */
private String formatUnits(int units) {
	switch (unitType) {
		case ENGLISH:
			return NumberFormat.getDecimalFormat().format(units) + (widthInUnitsIsMiles ? " mi" : " yd");
		case ENGLISH_FOOT:
			return NumberFormat.getDecimalFormat().format(units) + (widthInUnitsIsMiles ? " mi" : " ft");
		case METRIC:
			if (units < 10000) {
				return NumberFormat.getDecimalFormat().format(units) + " m";
			} else {
				return NumberFormat.getDecimalFormat().format((double) units / 1000) + " km";
			}

		case CRS:
			return NumberFormat.getDecimalFormat().format(units) + " u";

		default:
			return "??";
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:27,代码来源:Scalebar.java

示例12: getFormGroup

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
@Override
protected FormGroup getFormGroup(RenderMode renderMode) {
    slider = new Slider(field.getMin().doubleValue(),
                        field.getMax().doubleValue(),
                        field.getPrecision().doubleValue(),
                        field.getStep().doubleValue());

    slider.setId(generateUniqueId());
    slider.setEnabled(!field.getReadOnly() && renderingContext.getRenderMode().equals(RenderMode.EDIT_MODE));

    int precision = field.getPrecision().intValue();
    NumberFormat format = createFormatter(precision);
    slider.setFormatter((Double value) -> format.format(value));

    SliderFormGroup formGroup = formGroupsInstance.get();

    formGroup.render(slider,
                     field);

    return formGroup;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:22,代码来源:SliderFieldRenderer.java

示例13: createApplicationListener

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
@Override
 public ApplicationListener createApplicationListener() {
     instance = this;
     setLogLevel(LOG_NONE);
     setLoadingListener(new LoadingListener() {
         @Override
         public void beforeSetup() {

         }

         @Override
         public void afterSetup() {
             scaleCanvas();
             setupResizeHook();
         }
     });

     Net.setClientProvider(new WebsocketClient());
     
     Mindustry.platforms = new PlatformFunction(){
     	DateTimeFormat format = DateTimeFormat.getFormat("EEE, dd MMM yyyy HH:mm:ss");

@Override
public String format(Date date){
	return format.format(date);
}

@Override
public String format(int number){
	return NumberFormat.getDecimalFormat().format(number);
}

@Override
public void openLink(String link){
	Window.open(link, "_blank", "");
}
     };
     
     return new Mindustry();
 }
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:41,代码来源:HtmlLauncher.java

示例14: printMessage

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
public void printMessage(String eventName, int code, boolean modifier, boolean control) {
	final NumberFormat formatter = NumberFormat.getDecimalFormat();
	String message = eventName + " -  Char Code: " + formatter.format(code) + ".  ";

	if(code == KeyCodes.KEY_ENTER) {
		message += "Key is ENTER.  ";
	}

	if(modifier)
		message += "Modifier is down.  ";

	if(control)
		message += "CTRL is down.  ";
	logger.info("message"+message);
}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:16,代码来源:BaseWidget.java

示例15: getCell

import com.google.gwt.i18n.client.NumberFormat; //导入依赖的package包/类
protected Widget getCell(final InstructorInterface instructor, final InstructorsColumn column, final int idx) {
	switch (column) {
	case ID:
		if (instructor.getExternalId() == null) {
			Image warning = new Image(RESOURCES.warning());
			warning.setTitle(MESSAGES.warnInstructorHasNoExternalId(instructor.getFormattedName()));
			return warning;
		} else {
			return new Label(instructor.getExternalId());
		}
	case NAME:
		return new Label(instructor.getFormattedName());
	case POSITION:
		return new Label(instructor.getPosition() == null ? "" : instructor.getPosition().getLabel());
	case TEACHING_PREF:
		if (instructor.getTeachingPreference() == null) {
			return new Label("");
		} else {
			Label pref = new Label(instructor.getTeachingPreference().getName());
			if (instructor.getTeachingPreference().getColor() != null)
				pref.getElement().getStyle().setColor(instructor.getTeachingPreference().getColor());
			return pref;
		}
	case MAX_LOAD:
		return new Label(instructor.hasMaxLoad() ? NumberFormat.getFormat(CONSTANTS.teachingLoadFormat()).format(instructor.getMaxLoad()) : "");
	case SELECTION:
		return new SelectableCell(instructor);
	case ATTRIBUTES:
		AttributeTypeInterface type = iProperties.getAttributeTypes().get(idx);
		List<AttributeInterface> attributes = instructor.getAttributes(type);
		if (!attributes.isEmpty() && !isColumnVisible(getCellIndex(column) + idx)) {
			setColumnVisible(getCellIndex(column) + idx, true);
		}
		return new AttributesCell(attributes);
	default:
		return null;
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:39,代码来源:InstructorsTable.java


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