public String getString(final BigDecimal value) { if (value == null) { return ""; } return NumberFormatter.format(value, locale); }
/** * Uses the scale of the BigDecimal. Uses the ThreadLocalUserContext locale. * @param value */ public static String format(final BigDecimal value) { if (value == null) { return ""; } return format(value, value.scale()); }
/** * Uses the scale of the BigDecimal. * @param value * @param locale */ public static String format(final BigDecimal value, final Locale locale) { if (value == null) { return ""; } return format(value, value.scale(), locale); }
/** * Strips trailing zeros. * @param value e. g. 0.19 * @return e. g. 19% or empty string if value is null. * @see BigDecimal#stripTrailingZeros() */ public static String formatPercent(final BigDecimal value) { if (value == null) { return ""; } return format(value.multiply(NumberHelper.HUNDRED).stripTrailingZeros()) + "%"; } }
/** * @see org.apache.wicket.util.convert.converter.AbstractNumberConverter#convertToString(java.lang.Number, java.util.Locale) */ @Override public String convertToString(final BigDecimal value, final Locale locale) { if (value == null) { return "%"; } BigDecimal bd = value; if (decimalFormat == true) { bd = bd.multiply(NumberHelper.HUNDRED).stripTrailingZeros(); } return NumberFormatter.format(bd) + "%"; } }
/** * Uses the scale of the BigDecimal. Uses the ThreadLocalUserContext locale. * @param value */ public static String format(final BigDecimal value, final int scale) { return format(value, scale, ThreadLocalUserContext.getLocale()); }
private void addTitleAttribute(final Link<String> link, final AuftragsPositionVO pos, final BigDecimal totalPersonDays, final StringBuffer buf) { final StringBuffer tooltip = new StringBuffer(); tooltip.append(StringUtils.defaultString(pos.getAuftragTitle())).append(" (").append( NumberFormatter.format(totalPersonDays)).append(" ").append(getString("projectmanagement.personDays.short")).append(")"); if (pos.getAuftragsStatus() != null) { tooltip.append(", ").append(getString(pos.getAuftragsStatus().getI18nKey())); } WicketUtils.addTooltip(link, tooltip.toString(), buf.toString()); } }
private void addLabel(final Item<ICellPopulator<HRViewUserData>> item, final String componentId, final BigDecimal plannedDays, final BigDecimal actualDays) { final HRFilter filter = form.getSearchFilter(); final BigDecimal planned = filter.isShowPlanning() == true ? plannedDays : null; final BigDecimal actual = filter.isShowBookedTimesheets() == true ? actualDays : null; final StringBuffer buf = new StringBuffer(); if (NumberHelper.isNotZero(plannedDays) == true) { buf.append(NumberFormatter.format(planned, 2)); } if (NumberHelper.isNotZero(actualDays) == true) { buf.append(" (").append(NumberFormatter.format(actual, 2)).append(")"); } item.add(new Label(componentId, buf.toString())); }
@Override public void populateItem(final Item<ICellPopulator<AuftragDO>> item, final String componentId, final IModel<AuftragDO> rowModel) { item.add(new Label(componentId, NumberFormatter.format(rowModel.getObject().getPersonDays()))); item.add(AttributeModifier.append("style", new Model<String>("text-align: right;"))); cellItemListener.populateItem(item, componentId, rowModel); } });
public SystemStatisticsPage(final PageParameters parameters) { super(parameters); final JdbcTemplate jdbc = new JdbcTemplate(dataSource); body.add(new Label("totalNumberOfTimesheets", NumberFormatter.format(getTableCount(jdbc, TimesheetDO.class)))); final TaskTree taskTree = TaskTreeHelper.getTaskTree(); final long totalDuration = taskTree.getRootTaskNode().getDuration(taskTree, true); BigDecimal tatalPersonDays = new BigDecimal(totalDuration).divide(DateHelper.SECONDS_PER_WORKING_DAY, 2, BigDecimal.ROUND_HALF_UP); tatalPersonDays = NumberHelper.setDefaultScale(tatalPersonDays); body.add(new Label("totalNumberOfTimesheetDurations", NumberHelper.getNumberFractionFormat(getLocale(), tatalPersonDays.scale()) .format(tatalPersonDays))); body.add(new Label("totalNumberOfUsers", NumberFormatter.format(getTableCount(jdbc, PFUserDO.class)))); body.add(new Label("totalNumberOfTasks", NumberFormatter.format(getTableCount(jdbc, TaskDO.class)))); final int totalNumberOfHistoryEntries = getTableCount(jdbc, PfHistoryMasterDO.class) + getTableCount(jdbc, PfHistoryMasterDO.class); body.add(new Label("totalNumberOfHistoryEntries", NumberFormatter.format(totalNumberOfHistoryEntries))); }
buf.append("#").append(pos.getNumber()).append(": "); if (pos.getPersonDays() != null && pos.getPersonDays().compareTo(BigDecimal.ZERO) != 0) { buf.append("(").append(NumberFormatter.format(pos.getPersonDays())).append(" ") .append(getString("projectmanagement.personDays.short")).append(") "); buf.delete(buf.length() - 1, buf.length()); WicketUtils.addTooltip(label, NumberFormatter.format(auftrag.getPersonDays()) + " " + getString("projectmanagement.personDays.short"), buf.toString());
public HRListEntryPanel(final String id, final HRFilter filter, final BigDecimal plannedDays, final BigDecimal actualDays, final Link< ? > link) { super(id); final BigDecimal planned = filter.isShowPlanning() == true ? plannedDays : null; final BigDecimal actual = filter.isShowBookedTimesheets() == true ? actualDays : null; final Label plannedDaysLabel = new Label("plannedDays", NumberFormatter.format(planned, 2)); add(plannedDaysLabel.setRenderBodyOnly(true)); if (NumberHelper.isNotZero(plannedDays) == false) { plannedDaysLabel.setVisible(false); } add(link); final Label actualDaysLabel = new Label("actualDays", "(" + NumberFormatter.format(actual, 2) + ")"); link.add(actualDaysLabel.setRenderBodyOnly(true)); if (NumberHelper.isNotZero(actualDays) == false) { link.setVisible(false); } } }
buf.append(NumberFormatter.format(orderPosition.getPersonDays())); totalPersonDays = totalPersonDays.add(orderPosition.getPersonDays()); } else {
@SuppressWarnings("serial") private void addDurationColumns(final Item<GanttTreeTableNode> item, final GanttTreeTableNode node, final GanttTask ganttObject, final TaskDO task) { final MinMaxNumberField<BigDecimal> durationField = new MinMaxNumberField<BigDecimal>("duration", new PropertyModel<BigDecimal>( ganttObject, "duration"), BigDecimal.ZERO, TaskEditForm.MAX_DURATION_DAYS); addColumn(item, durationField, null); new RejectSaveLinksFragment("rejectSaveDuration", item, durationField, task, task != null ? NumberFormatter.format(task.getDuration(), 2) : "") { @Override protected void onSave() { task.setDuration(ganttObject.getDuration()); taskDao.update(task); } @Override protected void onReject() { ganttObject.setDuration(task.getDuration()); } }; }
add(new Label("timeOfSearch", NumberFormatter.format(duration)));