@Test public void callToConvertAddsMoreSupportedFormatsToTheContext() throws Exception { ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(LocalTime.class)).build(); LocalTimeConverter converter = new LocalTimeConverter(); converter.convert("", context); assertThat(context.getSupportedFormats().toString()).contains(" (LocalTimeConverter)"); }
@Override public LocalTime convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalTime.now().toString()); if(value==null){ return null; } try{ return LocalTime.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalTime: " + value); return null; } }
LocalTimeConverter implements PropertyConverter<LocalTime> { @Override public LocalTime convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalTime.now().toString()); if(value==null){ return null; } try{ return LocalTime.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalTime: " + value); return null; } } }
LocalTimeConverter implements PropertyConverter<LocalTime> { @Override public LocalTime convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalTime.now().toString()); if(value==null){ return null; } try{ return LocalTime.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalTime: " + value); return null; } }  }
LocalTimeConverter implements PropertyConverter<LocalTime> { @Override public LocalTime convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalTime.now().toString()); if(value==null){ return null; } try{ return LocalTime.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalTime: " + value); return null; } }  @Override LocalTime convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode(); }
LocalTimeConverter implements PropertyConverter<LocalTime> { @Override public LocalTime convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(), LocalTime.now().toString()); if(value==null){ return null; } try{ return LocalTime.parse(value); }catch(Exception e){ LOG.log(Level.FINEST, e, () -> "Cannot parse LocalTime: " + value); return null; } }  @Override LocalTime convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode();  }