Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterRegistry;
import org.springframework.format.datetime.DateFormatterRegistrar;

/**
* Installs lower-level type converters required to integrate
Expand All @@ -52,8 +51,6 @@ private DateTimeConverters() {
* @param registry the converter registry
*/
public static void registerConverters(ConverterRegistry registry) {
DateFormatterRegistrar.addDateConverters(registry);

registry.addConverter(new LocalDateTimeToLocalDateConverter());
registry.addConverter(new LocalDateTimeToLocalTimeConverter());
registry.addConverter(new ZonedDateTimeToLocalDateConverter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,24 @@ void proxiedConverterFactory() {
assertThat(formattingService.convert("1", Integer.class)).isEqualTo(Integer.valueOf(1));
}

@Test
void defaultFormattingConversionServiceHasNoDuplicateDateConverters() {
DefaultFormattingConversionService service = new DefaultFormattingConversionService();
String serviceString = service.toString();
int count = countOccurrences(serviceString, "DateFormatterRegistrar$DateToLongConverter");
assertThat(count).isEqualTo(1);
}

private int countOccurrences(String str, String subStr) {
int count = 0;
int idx = 0;
while ((idx = str.indexOf(subStr, idx)) != -1) {
count++;
idx += subStr.length();
}
return count;
}


static class NullReturningFormatter implements Formatter<Integer> {

Expand Down