MillisecondsToSecondsConverter implements Converter<Long, String> { @Override public Long toModelValue(final String time) { if (time == null || time.trim().equals("")) { return 0L; } try { return Long.valueOf(time); } catch (NumberFormatException ex){ return 0L; } }  @Override Long toModelValue(final String time); @Override String toWidgetValue(final Long time); @Override Class<Long> getModelType(); @Override Class<String> getComponentType();  }
@Test public void testToModelValue() { assertEquals(0, converter.toModelValue(null).longValue()); assertEquals(0, converter.toModelValue("").longValue()); assertEquals(0, converter.toModelValue(" ").longValue()); assertEquals(1, converter.toModelValue("1").longValue()); assertEquals(0, converter.toModelValue("abc").longValue()); }