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