@Test public void convert() throws Exception { LocalTimeConverter conv = new LocalTimeConverter(); LocalTime value = conv.convert("10:15:30", context); assertThat(LocalTime.parse("10:15:30")).isEqualTo(value); value = conv.convert("foo", context); assertThat(value).isNull(); }
@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();  }