@Test public void shouldBeAbleToConvertEmpty() { assertThat(converter.convert("", Float.class, bundle), is(nullValue())); }
public Float convert(String value, Class<? extends Float> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } try { final Locale locale = localization.getLocale(); DecimalFormat fmt = (DecimalFormat) DecimalFormat.getInstance(locale); return fmt.parse(value).floatValue(); } catch (ParseException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_number"), value)); } }
LocaleBasedFloatConverter implements Converter<Float> { public Float convert(String value, Class<? extends Float> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } try { final Locale locale = localization.getLocale(); DecimalFormat fmt = (DecimalFormat) DecimalFormat.getInstance(locale); return fmt.parse(value).floatValue(); } catch (ParseException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_number"), value)); } } }
LocaleBasedFloatConverter implements Converter<Float> { public Float convert(String value, Class<? extends Float> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } try { final Locale locale = localization.getLocale(); DecimalFormat fmt = (DecimalFormat) DecimalFormat.getInstance(locale); return fmt.parse(value).floatValue(); } catch (ParseException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_number"), value)); } } LocaleBasedFloatConverter(Localization localization); }
LocaleBasedFloatConverter implements Converter<Float> { public Float convert(String value, Class<? extends Float> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } try { final Locale locale = localization.getLocale(); DecimalFormat fmt = (DecimalFormat) DecimalFormat.getInstance(locale); return fmt.parse(value).floatValue(); } catch (ParseException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_number"), value)); } } LocaleBasedFloatConverter(Localization localization); Float convert(String value, Class<? extends Float> type, ResourceBundle bundle); }
LocaleBasedFloatConverter implements Converter<Float> { public Float convert(String value, Class<? extends Float> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return null; } try { final Locale locale = localization.getLocale(); DecimalFormat fmt = (DecimalFormat) DecimalFormat.getInstance(locale); return fmt.parse(value).floatValue(); } catch (ParseException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_number"), value)); } } LocaleBasedFloatConverter(Localization localization); Float convert(String value, Class<? extends Float> type, ResourceBundle bundle);  }