當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。