@Test public void shouldThrowExceptionWhenUnableToParse() { when(request.getAttribute("javax.servlet.jsp.jstl.fmt.locale.request")) .thenReturn("pt_br"); try { converter.convert("a,10/06/2008/a/b/c", LocalDateTime.class, bundle); } catch (ConversionError e) { assertThat(e.getMessage(), is(equalTo("a,10/06/2008/a/b/c is not a valid datetime."))); } }
public LocalDateTime convert(String value, Class<? extends LocalDateTime> type, ResourceBundle bundle) { try { DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDateTime()); if (out == null) { return null; } return out.toLocalDateTime(); } catch (Exception e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value)); } }
LocalDateTimeConverter implements Converter<LocalDateTime> { public LocalDateTime convert(String value, Class<? extends LocalDateTime> type, ResourceBundle bundle) { try { DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDateTime()); if (out == null) { return null; } return out.toLocalDateTime(); } catch (Exception e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value)); } } }
LocalDateTimeConverter implements Converter<LocalDateTime> { public LocalDateTime convert(String value, Class<? extends LocalDateTime> type, ResourceBundle bundle) { try { DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDateTime()); if (out == null) { return null; } return out.toLocalDateTime(); } catch (Exception e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value)); } } LocalDateTimeConverter(Localization localization); }
LocalDateTimeConverter implements Converter<LocalDateTime> { public LocalDateTime convert(String value, Class<? extends LocalDateTime> type, ResourceBundle bundle) { try { DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDateTime()); if (out == null) { return null; } return out.toLocalDateTime(); } catch (Exception e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value)); } } LocalDateTimeConverter(Localization localization); LocalDateTime convert(String value, Class<? extends LocalDateTime> type, ResourceBundle bundle); }
LocalDateTimeConverter implements Converter<LocalDateTime> { public LocalDateTime convert(String value, Class<? extends LocalDateTime> type, ResourceBundle bundle) { try { DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDateTime()); if (out == null) { return null; } return out.toLocalDateTime(); } catch (Exception e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value)); } } LocalDateTimeConverter(Localization localization); LocalDateTime convert(String value, Class<? extends LocalDateTime> type, ResourceBundle bundle);  }