public String render(Number object) { if (object == null) { return ""; } return format.format(object); } }
public String render(Double object) { if (object == null) { return ""; } return NumberFormat.getDecimalFormat().format(object); } }
public String render(Integer object) { if (null == object) { return ""; } return NumberFormat.getDecimalFormat().format(object); } }
public String render(Long object) { if (object == null) { return ""; } return NumberFormat.getDecimalFormat().format(object); } }
/** * Format a possibly scaled long value. * * @param value value to format * @param scale the number of places to the right the decimal point should * be moved in the digit string -- negative means the value contains * fractional digits * @return formatted value */ protected String format(long value, int scale) { boolean isNegative = value < 0; if (isNegative) { value = -value; } value *= multiplier; StringBuilder buf = new StringBuilder(); buf.append(String.valueOf(value)); format(isNegative, buf, scale); return buf.toString(); }
StringBuilder buf = new StringBuilder(); buf.append(bigDec.unscaledValue().toString()); format(isNegative, buf, -bigDec.scale()); return buf.toString(); } else if (number instanceof BigInteger) { StringBuilder buf = new StringBuilder(); buf.append(bigInt.toString()); format(isNegative, buf, 0); return buf.toString(); } else if (number instanceof Long) { return format(number.longValue(), 0); } else { return format(number.doubleValue());
@Override public void render(Context context, Number value, SafeHtmlBuilder sb) { if (value != null) { sb.append(renderer.render(format.format(value))); } } }
format(isNegative, buf, scale); return buf.toString();
/** * 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); }
/** * Provides the standard currency format for the default locale. * * @param value the value * @return the currency value */ public static String currency(double value) { return NumberFormat.getCurrencyFormat().format(value); }
/** * Provides the standard scientific format for the default locale. * * @param value the value * @return the value */ public static String scientific(double value) { return NumberFormat.getScientificFormat().format(value); }
@Override public String render(BigInteger object) { if (object == null) { return ""; } return NumberFormat.getDecimalFormat().format(object); }
@Override public String render(BigDecimal object) { if (object == null) { return ""; } return NumberFormat.getDecimalFormat().format(object); }
public String render(Long object) { if (object == null) { return ""; } return NumberFormat.getDecimalFormat().format(object); } }
@Override public String getLabel(M item, ValueProvider<? super M, ? extends Number> valueProvider) { return format.format(valueProvider.getValue(item)); } };
public String render(BigDecimal object) { if (null == object) { return ""; } return NumberFormat.getDecimalFormat().format(object); } }
public String render(Double object) { if (object == null) { return ""; } return NumberFormat.getDecimalFormat().format(object); } }
String humanReadableRowCount(long rows) { int unit = 1000; if (rows < unit) return Long.toString(rows); int exp = (int) (Math.log(rows) / Math.log(unit)); String pre = ("KMGTPE" ).charAt(exp-1) + (""); return NumberFormat.getFormat(ESTIMATIONS_FORMAT).format(rows / Math.pow(unit, exp)) + pre; }
public String render(Double object) { if (object == null) { return ""; } return NumberFormat.getDecimalFormat().format(object); } }