@Test public void convert() throws Exception { LocalDateConverter conv = new LocalDateConverter(); LocalDate value = conv.convert("2007-12-03", context); assertThat(LocalDate.parse("2007-12-03")).isEqualTo(value); value = conv.convert("foo", context); assertThat(value).isNull(); }
@Override public LocalDate convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalDate.now().toString()); if(value==null){ return null; } try{ return LocalDate.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalDate: " + value); return null; } }
LocalDateConverter implements PropertyConverter<LocalDate> { @Override public LocalDate convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalDate.now().toString()); if(value==null){ return null; } try{ return LocalDate.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalDate: " + value); return null; } } }
LocalDateConverter implements PropertyConverter<LocalDate> { @Override public LocalDate convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalDate.now().toString()); if(value==null){ return null; } try{ return LocalDate.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalDate: " + value); return null; } }  }
LocalDateConverter implements PropertyConverter<LocalDate> { @Override public LocalDate convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalDate.now().toString()); if(value==null){ return null; } try{ return LocalDate.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalDate: " + value); return null; } }  @Override LocalDate convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode(); }
LocalDateConverter implements PropertyConverter<LocalDate> { @Override public LocalDate convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalDate.now().toString()); if(value==null){ return null; } try{ return LocalDate.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalDate: " + value); return null; } }  @Override LocalDate convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode();  }