use of org.springframework.format.support.FormattingConversionService in project spring-boot by spring-projects.
the class WebFluxAutoConfigurationTests method customTimeFormat.
@Test
void customTimeFormat() {
this.contextRunner.withPropertyValues("spring.webflux.format.time=HH:mm:ss").run((context) -> {
FormattingConversionService conversionService = context.getBean(FormattingConversionService.class);
LocalTime time = LocalTime.of(11, 43, 10);
assertThat(conversionService.convert(time, String.class)).isEqualTo("11:43:10");
});
}
use of org.springframework.format.support.FormattingConversionService in project spring-boot by spring-projects.
the class WebFluxAutoConfigurationTests method defaultTimeFormat.
@Test
void defaultTimeFormat() {
this.contextRunner.run((context) -> {
FormattingConversionService conversionService = context.getBean(FormattingConversionService.class);
LocalTime time = LocalTime.of(11, 43, 10);
assertThat(conversionService.convert(time, String.class)).isEqualTo(DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT).format(time));
});
}
use of org.springframework.format.support.FormattingConversionService in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method defaultTimeFormat.
@Test
void defaultTimeFormat() {
this.contextRunner.run((context) -> {
FormattingConversionService conversionService = context.getBean(FormattingConversionService.class);
LocalTime time = LocalTime.of(11, 43, 10);
assertThat(conversionService.convert(time, String.class)).isEqualTo(DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT).format(time));
});
}
use of org.springframework.format.support.FormattingConversionService in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method customTimeFormat.
@Test
void customTimeFormat() {
this.contextRunner.withPropertyValues("spring.mvc.format.time=HH:mm:ss").run((context) -> {
FormattingConversionService conversionService = context.getBean(FormattingConversionService.class);
LocalTime time = LocalTime.of(11, 43, 10);
assertThat(conversionService.convert(time, String.class)).isEqualTo("11:43:10");
});
}
use of org.springframework.format.support.FormattingConversionService in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method customDateFormatWithDeprecatedProperty.
@Test
void customDateFormatWithDeprecatedProperty() {
this.contextRunner.withPropertyValues("spring.mvc.date-format:dd*MM*yyyy").run((context) -> {
FormattingConversionService conversionService = context.getBean(FormattingConversionService.class);
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");
});
}
Aggregations