DateTimeNAConverter implements Converter<Date, String> { @Override public String toWidgetValue(final Date date) { final String dateTimeStr = DateUtils.getDateTimeStr(date); return dateTimeStr.trim().isEmpty() ? constants.NA() : dateTimeStr; }  @Override Date toModelValue(final String value); @Override String toWidgetValue(final Date date); @Override Class<Date> getModelType(); @Override Class<String> getComponentType();  }
@Test public void testToWidgetValue() { Date date = new Date(); String dateStr = converter.toWidgetValue(date); final String expected = new SimpleDateFormat("dd/MM/yyyy HH:mm").format(date); assertEquals(expected, dateStr); }
@Test public void testToWidgetValueEmpty() { String dateStr = converter.toWidgetValue(null); assertEquals(Constants.INSTANCE.NA(), dateStr); }