LocalDateConverter implements Converter { @Override public String getAsString(FacesContext context, UIComponent component, Object value) { if (null == value) { return ""; } return ((LocalDate) value).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); }  @Override Object getAsObject(FacesContext context, UIComponent component, String value); @Override String getAsString(FacesContext context, UIComponent component, Object value);  }
@Test public void localdates_are_converted_to_strings_using_us_locale() { String value = new LocalDateConverter().getAsString(mock(FacesContext.class), mock(UIComponent.class), LocalDate.of(2012, APRIL, 3)); assertThat(value).isEqualTo("2012-04-03"); }
@Test public void null_localdates_are_converted_to_empty_strings() { String value = new LocalDateConverter().getAsString(mock(FacesContext.class), mock(UIComponent.class), null); assertThat(value).isEqualTo(""); }