Use ResolverStyle.SMART when a custom format is specified

Fixes gh-13970
pull/14085/merge
Madhura Bhave 6 years ago
parent 51fd27fad4
commit f7135ff18f

@ -89,7 +89,7 @@ public class WebConversionService extends DefaultFormattingConversionService {
DateTimeFormatterRegistrar dateTime = new DateTimeFormatterRegistrar();
if (this.dateFormat != null) {
dateTime.setDateFormatter(DateTimeFormatter.ofPattern(this.dateFormat)
.withResolverStyle(ResolverStyle.STRICT));
.withResolverStyle(ResolverStyle.SMART));
}
dateTime.registerFormatters(this);
}

@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link WebConversionService}.
*
* @author Brian Clozel
* @author Madhura Bhave
*/
public class WebConversionServiceTests {
@ -44,4 +45,12 @@ public class WebConversionServiceTests {
.isEqualTo("01*01*2018");
}
@Test
public void convertFromStringToDate() {
WebConversionService conversionService = new WebConversionService("yyyy-MM-dd");
java.time.LocalDate date = conversionService.convert("2018-01-01",
java.time.LocalDate.class);
assertThat(date).isEqualTo(java.time.LocalDate.of(2018, 1, 1));
}
}

Loading…
Cancel
Save