Package com.google.gwt.i18n.client

Examples of com.google.gwt.i18n.client.NumberFormat


   *
   * @return the text
   */
  protected String createText() {
    // Default text is 1 based.
    NumberFormat formatter = NumberFormat.getFormat("#,###");
    HasRows display = getDisplay();
    Range range = display.getVisibleRange();
    int pageStart = range.getStart() + 1;
    int pageSize = range.getLength();
    int dataSize = display.getRowCount();
    int endIndex = Math.min(dataSize, pageStart + pageSize - 1);
    endIndex = Math.max(pageStart, endIndex);
    boolean exact = display.isRowCountExact();
    return formatter.format(pageStart) + "-" + formatter.format(endIndex)
        + (exact ? " of " : " of over ") + formatter.format(dataSize);
  }
View Full Code Here


    } else {
      throw new JavaScriptException("Table Element must ");
    }

    String dateFormat = "MM-dd-yy";
    NumberFormat numberFormats[] = new NumberFormat[numCols];

    NodeList<com.google.gwt.dom.client.Element> colGroup = te
        .getElementsByTagName("colgroup");
    assertTrue(colGroup != null && colGroup.getLength() == 1,
        "Table must have exactly one COLGROUP element");
View Full Code Here

              continue;
            }
          }
        }

        NumberFormat format = config.getSummaryFormat(name);
        if (format != null && value != null) {
          String svalue = format.format(value.doubleValue());
          footer.setHtml(j, svalue);
          continue;
        }

        AggregationRenderer<?> renderer = config.getRenderer(name);
View Full Code Here

    private DateTimeFormat shortDateFormat = DateTimeFormat.getShortDateFormat();

    public String formatCurrency(long amount, String currencyCode, boolean international, boolean showGroupings) {
        int decimalPlaces = getDecimalPlaces(currencyCode);
        final double doubleValue = MathUtil.fixedPointToDouble(amount, decimalPlaces);
        final NumberFormat format = getNumberFormat(currencyCode, international, decimalPlaces);
        return format.format(doubleValue);
    }  
View Full Code Here

    }  

  public String formatCurrency(BigDecimal amount, String currencyCode, boolean international, boolean showGroupings) {
    int decimalPlaces = getDecimalPlaces(currencyCode);
        final double doubleValue = amount.scaleByPowerOfTen(-decimalPlaces).doubleValue();
        final NumberFormat format = getNumberFormat(currencyCode, international, Math.max(decimalPlaces, amount.scale()));
       
        return format.format(doubleValue);
  }
View Full Code Here

        case 8: fmt = international?"\u00a4\u00a4#,##0.00000000;\u00a4\u00a4-#,##0.00000000":"\u00a4#,##0.00000000;\u00a4-#,##0.00000000"; break;
        case 9: fmt = international?"\u00a4\u00a4#,##0.000000000;\u00a4\u00a4-#,##0.000000000":"\u00a4#,##0.000000000;\u00a4-#,##0.000000000"; break;
        case 10: fmt = international?"\u00a4\u00a4#,##0.0000000000;\u00a4\u00a4-#,##0.0000000000":"\u00a4#,##0.0000000000;\u00a4-#,##0.0000000000"; break;
        default: throw new IllegalArgumentException("Currency "+currencyCode+" not supported because it has "+decimalPlaces+" decimal places!");
        }
        final NumberFormat format = NumberFormat.getFormat(fmt, currencyCode);
        return format;
    }
View Full Code Here

    ColumnConfig c = cm.getColumn(colIndex);

    if (val != null && c.getNumberFormat() != null) {
      Number n = (Number) val;
      NumberFormat nf = cm.getColumn(colIndex).getNumberFormat();
      val = nf.format(n.doubleValue());
    } else if (val != null && c.getDateTimeFormat() != null) {
      DateTimeFormat dtf = c.getDateTimeFormat();
      val = dtf.format((Date) val);
    }
View Full Code Here

  private String memToMB(String mem)
  {
    double value = Double.parseDouble(mem);
    double valued = (double)value / 1024.0 / 1024.0;
   
    NumberFormat df = NumberFormat.getFormat("#0.00 mb");
   
    return df.format(valued);
  }
View Full Code Here

import com.google.gwt.i18n.client.NumberFormat;

public class NumberFormatExample implements EntryPoint {

  public void onModuleLoad() {
    NumberFormat fmt = NumberFormat.getDecimalFormat();
    double value = 12345.6789;
    String formatted = fmt.format(value);
    // Prints 1,2345.6789 in the default locale
    GWT.log("Formatted string is" + formatted);

    // Turn a string back into a double
    value = NumberFormat.getDecimalFormat().parse("12345.6789");
    GWT.log("Parsed value is" + value);

    // Scientific notation
    value = 12345.6789;
    formatted = NumberFormat.getScientificFormat().format(value);
    // prints 1.2345E4 in the default locale
    GWT.log("Formatted string is" + formatted);

    // Currency
    fmt = NumberFormat.getCurrencyFormat();
    formatted = fmt.format(123456.7899);
    // prints US$123,456.79 in the default locale or $123,456.79 in the en_US
    // locale
    GWT.log("Formatted currency is" + formatted);
   
    // Custom format
View Full Code Here

    int row = stocks.indexOf(stockPrice.getSymbol()) + 1;
   
      // Format the data in the Price and Change fields.
      String priceText = NumberFormat.getFormat("#,##0.00").format(stockPrice.getPrice());
      NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
      String changeText = changeFormat.format(stockPrice.getChange());
      String changePercentText = changeFormat.format(stockPrice.getChangePercent());

      // Populate the Price and Change fields with new data.
      stocksFlexTable.setText(row, 1, priceText);
      //Use the line of code without styling
      //stocksFlexTable.setText(row, 2, changeText + " (" + changePercentText + "%)");
View Full Code Here

TOP

Related Classes of com.google.gwt.i18n.client.NumberFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.