|
|
|
@ -16,6 +16,8 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.web.servlet;
|
|
|
|
|
|
|
|
|
|
import java.time.ZoneId;
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
@ -30,7 +32,6 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.ValidatorFactory;
|
|
|
|
|
|
|
|
|
|
import org.joda.time.DateTime;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
@ -321,7 +322,7 @@ class WebMvcAutoConfigurationTests {
|
|
|
|
|
void noDateFormat() {
|
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
|
FormattingConversionService conversionService = context.getBean(FormattingConversionService.class);
|
|
|
|
|
Date date = new DateTime(1988, 6, 25, 20, 30).toDate();
|
|
|
|
|
Date date = Date.from(ZonedDateTime.of(1988, 6, 25, 20, 30, 0, 0, ZoneId.systemDefault()).toInstant());
|
|
|
|
|
// formatting conversion service should use simple toString()
|
|
|
|
|
assertThat(conversionService.convert(date, String.class)).isEqualTo(date.toString());
|
|
|
|
|
});
|
|
|
|
@ -331,7 +332,7 @@ class WebMvcAutoConfigurationTests {
|
|
|
|
|
void overrideDateFormat() {
|
|
|
|
|
this.contextRunner.withPropertyValues("spring.mvc.date-format:dd*MM*yyyy").run((context) -> {
|
|
|
|
|
FormattingConversionService conversionService = context.getBean(FormattingConversionService.class);
|
|
|
|
|
Date date = new DateTime(1988, 6, 25, 20, 30).toDate();
|
|
|
|
|
Date date = Date.from(ZonedDateTime.of(1988, 6, 25, 20, 30, 0, 0, ZoneId.systemDefault()).toInstant());
|
|
|
|
|
assertThat(conversionService.convert(date, String.class)).isEqualTo("25*06*1988");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|