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