@Test public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception { ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(LocalDate.class)).build(); LocalDateConverter converter = new LocalDateConverter(); converter.convert("", context); assertThat(context.getSupportedFormats().toString()).contains(" (LocalDateConverter)"); }
@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();  }