Search in sources :

Example 1 with NumberFormat

use of com.google.gwt.i18n.client.NumberFormat in project gwt-test-utils by gwt-test-utils.

the class NumberFormatTest method numberFormat_SpecificPatternWithDouble.

@Test
public void numberFormat_SpecificPatternWithDouble() {
    // Given
    setLocale(Locale.FRENCH);
    NumberFormat numberFormat = NumberFormat.getFormat("0000000000");
    // When
    String numberString = numberFormat.format(42147482);
    // Then
    assertThat(numberString).isEqualTo("0042147482");
}
Also used : NumberFormat(com.google.gwt.i18n.client.NumberFormat) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Example 2 with NumberFormat

use of com.google.gwt.i18n.client.NumberFormat in project blogwt by billy1380.

the class SimplePager method createText.

/**
 * Get the text to display in the pager that reflects the state of the pager.
 *
 * @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);
}
Also used : HasRows(com.google.gwt.view.client.HasRows) Range(com.google.gwt.view.client.Range) NumberFormat(com.google.gwt.i18n.client.NumberFormat)

Example 3 with NumberFormat

use of com.google.gwt.i18n.client.NumberFormat in project gwt-test-utils by gwt-test-utils.

the class NumberFormatTest method numberFormat_SpecificPattern.

@Test
public void numberFormat_SpecificPattern() {
    // Given
    setLocale(Locale.FRENCH);
    NumberFormat numberFormat = NumberFormat.getFormat("0000000000");
    // When
    String numberString = numberFormat.format(1234);
    // Then
    assertThat(numberString).isEqualTo("0000001234");
}
Also used : NumberFormat(com.google.gwt.i18n.client.NumberFormat) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Aggregations

NumberFormat (com.google.gwt.i18n.client.NumberFormat)3 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)2 Test (org.junit.Test)2 HasRows (com.google.gwt.view.client.HasRows)1 Range (com.google.gwt.view.client.Range)1