@Test public void valid_strings_are_converted_to_matching_localdates() { Object localDate = new LocalDateConverter().getAsObject(mock(FacesContext.class), mock(UIComponent.class), "2012-04-05"); assertThat(localDate).isEqualTo(LocalDate.of(2012, APRIL, 5)); }
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (isBlank(value)) { return null; } try { return LocalDate.parse(value); } catch (DateTimeParseException e) { throw new ConverterException(new FacesMessage(SEVERITY_ERROR, "Please provide a date using a format like 2014-12-24", null), e); } }
LocalDateConverter implements Converter { @Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (isBlank(value)) { return null; } try { return LocalDate.parse(value); } catch (DateTimeParseException e) { throw new ConverterException(new FacesMessage(SEVERITY_ERROR, "Please provide a date using a format like 2014-12-24", null), e); } } }
LocalDateConverter implements Converter { @Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (isBlank(value)) { return null; } try { return LocalDate.parse(value); } catch (DateTimeParseException e) { throw new ConverterException(new FacesMessage(SEVERITY_ERROR, "Please provide a date using a format like 2014-12-24", null), e); } }  }
LocalDateConverter implements Converter { @Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (isBlank(value)) { return null; } try { return LocalDate.parse(value); } catch (DateTimeParseException e) { throw new ConverterException(new FacesMessage(SEVERITY_ERROR, "Please provide a date using a format like 2014-12-24", null), e); } }  @Override Object getAsObject(FacesContext context, UIComponent component, String value); @Override String getAsString(FacesContext context, UIComponent component, Object value); }
LocalDateConverter implements Converter { @Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (isBlank(value)) { return null; } try { return LocalDate.parse(value); } catch (DateTimeParseException e) { throw new ConverterException(new FacesMessage(SEVERITY_ERROR, "Please provide a date using a format like 2014-12-24", null), e); } }  @Override Object getAsObject(FacesContext context, UIComponent component, String value); @Override String getAsString(FacesContext context, UIComponent component, Object value);  }