@Test public void convert() throws Exception { OffsetDateTimeConverter conv = new OffsetDateTimeConverter(); OffsetDateTime value = conv.convert("2007-12-03T10:15:30+01:00", context); assertThat(OffsetDateTime.parse("2007-12-03T10:15:30+01:00")).isEqualTo(value); value = conv.convert("foo", context); assertThat(value).isNull(); }
@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();  }