@Test public final void shouldFormatDecimalWithoutOfficiousTrimmingFractionalValue2() { final String decimalAsString = "1234567." + StringUtils.repeat("9", NumberService.DEFAULT_MAX_FRACTION_DIGITS_IN_DECIMAL) + "000001"; BigDecimal value = new BigDecimal(decimalAsString); String result = decimalType.toString(value, locale); assertFormattedEquals(value, result); }
@Override public String toString(final Object value, final Locale locale) { if (value == null) { return ""; } if(value instanceof String){ return (String) value; } NumberFormat format = null; if (locale == null) { format = NumberFormat.getNumberInstance(); } else { format = NumberFormat.getNumberInstance(locale); } format.setMaximumFractionDigits(getMaxFractionDigits(value)); return format.format(value); }
DecimalType extends AbstractFieldType implements DefaultValidatorsProvider { @Override public String toString(final Object value, final Locale locale) { if (value == null) { return ""; } if(value instanceof String){ return (String) value; } NumberFormat format = null; if (locale == null) { format = NumberFormat.getNumberInstance(); } else { format = NumberFormat.getNumberInstance(locale); } format.setMaximumFractionDigits(getMaxFractionDigits(value)); return format.format(value); } }
DecimalType extends AbstractFieldType implements DefaultValidatorsProvider { @Override public String toString(final Object value, final Locale locale) { if (value == null) { return ""; } if(value instanceof String){ return (String) value; } NumberFormat format = null; if (locale == null) { format = NumberFormat.getNumberInstance(); } else { format = NumberFormat.getNumberInstance(locale); } format.setMaximumFractionDigits(getMaxFractionDigits(value)); return format.format(value); } DecimalType();  DecimalType(final boolean copyable); }
DecimalType extends AbstractFieldType implements DefaultValidatorsProvider { @Override public String toString(final Object value, final Locale locale) { if (value == null) { return ""; } if(value instanceof String){ return (String) value; } NumberFormat format = null; if (locale == null) { format = NumberFormat.getNumberInstance(); } else { format = NumberFormat.getNumberInstance(locale); } format.setMaximumFractionDigits(getMaxFractionDigits(value)); return format.format(value); } DecimalType();  DecimalType(final boolean copyable); @Override Class<?> getType(); @Override ValueAndError toObject(final FieldDefinition fieldDefinition, final Object value); @Override String toString(final Object value, final Locale locale); @Override Object fromString(final String value, final Locale locale); @Override Collection<FieldHookDefinition> getMissingValidators(final Iterable<FieldHookDefinition> validators); }
DecimalType extends AbstractFieldType implements DefaultValidatorsProvider { @Override public String toString(final Object value, final Locale locale) { if (value == null) { return ""; } if(value instanceof String){ return (String) value; } NumberFormat format = null; if (locale == null) { format = NumberFormat.getNumberInstance(); } else { format = NumberFormat.getNumberInstance(locale); } format.setMaximumFractionDigits(getMaxFractionDigits(value)); return format.format(value); } DecimalType();  DecimalType(final boolean copyable); @Override Class<?> getType(); @Override ValueAndError toObject(final FieldDefinition fieldDefinition, final Object value); @Override String toString(final Object value, final Locale locale); @Override Object fromString(final String value, final Locale locale); @Override Collection<FieldHookDefinition> getMissingValidators(final Iterable<FieldHookDefinition> validators);  }