Example usage for com.google.gwt.i18n.client NumberFormat getCurrencyFormat

List of usage examples for com.google.gwt.i18n.client NumberFormat getCurrencyFormat

Introduction

In this page you can find the example usage for com.google.gwt.i18n.client NumberFormat getCurrencyFormat.

Prototype

public static NumberFormat getCurrencyFormat() 

Source Link

Document

Provides the standard currency format for the default locale.

Usage

From source file:org.broadleafcommerce.openadmin.client.BLCMain.java

License:Apache License

@Override
public void onModuleLoad() {

    NumericTypeFactory.registerNumericSimpleType("localDecimal", NumberFormat.getDecimalFormat(),
            SupportedFieldType.DECIMAL);
    NumericTypeFactory.registerNumericSimpleType("localMoneyDecimal", NumberFormat.getDecimalFormat(),
            SupportedFieldType.MONEY);//from w w  w . jav a2  s . co  m
    NumericTypeFactory.registerNumericSimpleType("localCurrency", NumberFormat.getCurrencyFormat(),
            SupportedFieldType.MONEY);

    addPreProcessor(new UrlStructurePreProcessor());
    addPreProcessor(new UserSecurityPreProcessor());
    addPreProcessor(new EJB3ConfigurationPreProcessor());
    addPreProcessor(new WorkflowEnabledPreProcessor());
}

From source file:org.cruxframework.crux.gwt.client.NumberFormatUtil.java

License:Apache License

/**
 * Gets a NumberFormat object based on the patternString parameter. 
 * @param patternString//from  w  w  w  .  j ava2 s .c om
 * @return
 */
public static NumberFormat getNumberFormat(String patternString) {
    NumberFormat result;

    if (DECIMAL_PATTERN.equals(patternString)) {
        result = NumberFormat.getDecimalFormat();
    } else if (CURRENCY_PATTERN.equals(patternString)) {
        result = NumberFormat.getCurrencyFormat();
    } else if (PERCENT_PATTERN.equals(patternString)) {
        result = NumberFormat.getPercentFormat();
    } else if (SCIENTIFIC_PATTERN.equals(patternString)) {
        result = NumberFormat.getScientificFormat();
    } else {
        result = NumberFormat.getFormat(patternString);
    }

    return result;
}

From source file:org.gk.engine.client.build.grid.field.GAggregationRowBuilder.java

License:Open Source License

/**
 * ?NumberFormat/*from   ww w .  j  a v a 2  s .co  m*/
 * 
 * @param format
 * @return NumberFormat
 */
private NumberFormat getSummaryFormat(String format) {
    NumberFormat nf = null;
    if (format.equalsIgnoreCase("currency")) {
        nf = NumberFormat.getCurrencyFormat();
    } else if (format.equalsIgnoreCase("scientific")) {
        nf = NumberFormat.getScientificFormat();
    } else if (format.equalsIgnoreCase("decimal")) {
        nf = NumberFormat.getDecimalFormat();
    } else if (format.equalsIgnoreCase("percent")) {
        nf = NumberFormat.getPercentFormat();
    } else {
        nf = NumberFormat.getFormat(format);
    }
    return nf;
}

From source file:org.opentaps.gwt.common.client.listviews.CurrencyColumnConfig.java

License:Open Source License

/**
 * The implementation of the <code>Renderer</code> interface that produce the content of the cell.
 * @param value the value of the current record for this cell
 * @param cellMetadata a <code>CellMetadata</code> value
 * @param record the current <code>Record</code> value
 * @param rowIndex the row index of the current record
 * @param colNum the column index of this cell
 * @param store a <code>Store</code> value
 * @return the cell content as an HTML string
 *//*w w  w .  j  a v a 2 s.  com*/
public String render(Object value, CellMetadata cellMetadata, Record record, int rowIndex, int colNum,
        Store store) {
    if (value == null) {
        return "";
    }
    String amount = (String) value;

    NumberFormat fmt = null;
    String currency = currencyCode;
    if (currencyIndex != null) {
        currencyCode = record.getAsString(currencyIndex);
    }
    if (currencyCode == null) {
        fmt = NumberFormat.getCurrencyFormat();
    } else {
        try {
            fmt = NumberFormat.getCurrencyFormat(currencyCode);
        } catch (Exception e) {
            // Note: there is a bug in getCurrencyFormat and it does not work by looking at the properties file
            // but is limited to 4 hard coded currencies
            UtilUi.logWarning(
                    "Cannot set currency format with currency code [" + currencyCode + "] " + e.getMessage(),
                    MODULE, "render");
            // manually build the format and use the currency code as the currency symbol
            // this pattern is the currency pattern but with the currency symbol removed
            fmt = NumberFormat.getFormat("#,##0.00;(#,##0.00)");
            return currencyCode + " " + fmt.format(new BigDecimal(amount).doubleValue());
        }
    }
    return fmt.format(new BigDecimal(amount).doubleValue());
}

From source file:org.zhengyang.aptmanagement.client.utils.Formatter.java

License:Apache License

public static String formatMoney(double money) {
    if (money < 0) {
        String temp = NumberFormat.getCurrencyFormat().format(money);
        return "-" + temp.substring(1, temp.length() - 1);
    }/*from w w  w  .j  av  a 2s . c  o  m*/
    return "+" + NumberFormat.getCurrencyFormat().format(money);
}