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