LocalDateWeekCodeConverter implements Converter<String, LocalDate> { @Override public String convertToPresentation(LocalDate value, ValueContext context) { if (value == null) { return ""; } return DateUtils.toWeekCode(value); }  @Override Result<LocalDate> convertToModel(String value, ValueContext context); @Override String convertToPresentation(LocalDate value, ValueContext context);  }
@Test public void testToPresentation() { String str = converter.convertToPresentation(null, new ValueContext()); assertEquals("", str); str = converter.convertToPresentation(DateUtils.createLocalDate("22122014"), new ValueContext()); assertEquals("2014-52", str); str = converter.convertToPresentation(DateUtils.createLocalDate("29122014"), new ValueContext()); assertEquals("2015-01", str); str = converter.convertToPresentation(DateUtils.createLocalDate("05012015"), new ValueContext()); assertEquals("2015-02", str); }