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


Java NumberFormat.getCurrencyFormat方法代码示例

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


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

示例1: updatePattern

import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
/**
 * Update the selected pattern based on the pattern in the list.
 */
@ShowcaseSource
private void updatePattern() {
  switch (patternList.getSelectedIndex()) {
    case 0:
      activeFormat = NumberFormat.getDecimalFormat();
      patternBox.setText(activeFormat.getPattern());
      patternBox.setEnabled(false);
      break;
    case 1:
      activeFormat = NumberFormat.getCurrencyFormat();
      patternBox.setText(activeFormat.getPattern());
      patternBox.setEnabled(false);
      break;
    case 2:
      activeFormat = NumberFormat.getScientificFormat();
      patternBox.setText(activeFormat.getPattern());
      patternBox.setEnabled(false);
      break;
    case 3:
      activeFormat = NumberFormat.getPercentFormat();
      patternBox.setText(activeFormat.getPattern());
      patternBox.setEnabled(false);
      break;
    case 4:
      patternBox.setEnabled(true);
      String pattern = patternBox.getText();
      try {
        activeFormat = NumberFormat.getFormat(pattern);
      } catch (IllegalArgumentException e) {
        showErrorMessage(constants.cwNumberFormatInvalidPattern());
        return;
      }
      break;
  }

  // Update the formatted value
  updateFormattedValue();
}
 
开发者ID:Peergos,项目名称:Peergos,代码行数:42,代码来源:CwNumberFormat.java

示例2: getFormattedPrice

import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
public static String getFormattedPrice(Integer price, Integer currency) {
	if (price == null) {
		price = 0;
	}
	NumberFormat nf = NumberFormat.getCurrencyFormat(PropertyOptions.currencyMap.get(currency));

	String priceStr = nf.format(price);
	priceStr = (currency < 2) ? priceStr.replaceFirst("TL", "") + " TL" : priceStr;

	return priceStr;
}
 
开发者ID:jchaganti,项目名称:gharonda,代码行数:12,代码来源:PropertyOptions.java

示例3: displayProperties

import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
@Override
public void displayProperties(List<PropertiesDTO> list) {
	setWindowTitle("İlanlarım - Gharonda.com");
	curList = list;
	FixedWidthGrid dataTable = propertiesGrid.getDataTable();
	dataTable.resize(list.size(), 8);
	int i = 0;
	for (PropertiesDTO p : list) {
		SelectionGridRowFormatter formatter = dataTable.getSelectionGridRowFormatter();
		if (i % 2 == 1) {
			formatter.getElement(i).getStyle().setBackgroundColor("#fcfef0");
		}
		CellFormatter cellFormatter = dataTable.getCellFormatter();
		dataTable.setWidget(i, 0, createCheckBox(p.getId()));

		dataTable.setWidget(i, 1, createModifyAnchor(p.getId()));
		cellFormatter.setAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);

		dataTable.setWidget(i, 2, createDeleteAnchor(p.getId()));
		cellFormatter.setAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
		String locale = PropertyOptions.getCurrentLocale();
		String detailsUrl = "javascript:window.open(\""
				+ PropertyOptions.getPropertyDetailPageUrl(p.getId(), locale) + "\");return false;";
		dataTable.setHTML(i, 3, "# <span style=\"font-weight:bold;color:#000;\" id=" + "pid_" + p.getId() + ">"
				+ "<a style=\"color:#000;\" onClick='" + detailsUrl + "'>" + p.getId() + "</a>" + " </span>");
		cellFormatter.setAlignment(i, 3, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);

		dataTable.setHTML(i, 4, "<span   id=" + "title_" + p.getId() + ">" + "<a style=\"color:#000;\" onClick='"
				+ detailsUrl + "'>" + p.getTitle() + "</a>" + " </span>");
		cellFormatter.setAlignment(i, 4, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);

		Integer price = (p.getPrice() == null) ? 0 : p.getPrice();
		NumberFormat nf = NumberFormat.getCurrencyFormat(PropertyOptions.currencyMap.get(p.getCurrency()));

		String value = nf.format(price);
		value = (p.getCurrency() < 2) ? value.replaceFirst("TL", "") + " TL" : value;

		dataTable.setHTML(i, 5, value);
		cellFormatter.setAlignment(i, 5, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);

		dataTable.setHTML(i, 6, PropertyOptions.getFormattedDate(p.getTimeStamp()));

		cellFormatter.setAlignment(i, 6, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);

		// String isActive = (i%2 == 0) ?
		// "<img width=\"22\" height=\"23\" src=\"images/Red-x.GIF\"/>"
		// : "<img width=\"22\" height=\"23\" src=\"images/tick2.gif\"/>";
		String isActive = (p.getIsactive() == null || p.getIsactive() == 0) ? "<img width=\"22\" height=\"23\" src=\"images/Red-x.GIF\"/>"
				: "<img width=\"22\" height=\"23\" src=\"images/tick2.gif\"/>";

		cellFormatter.setAlignment(i, 7, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
		dataTable.setHTML(i, 7, isActive);
		i++;
	}
	propertiesGrid.redraw();
}
 
开发者ID:jchaganti,项目名称:gharonda,代码行数:57,代码来源:MyListingsView.java


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