use of org.springframework.format.support.FormattingConversionService in project spring-boot by spring-projects.
the class WebFluxAutoConfigurationTests method customDateFormat.
@Test
void customDateFormat() {
this.contextRunner.withPropertyValues("spring.webflux.format.date: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");
});
}
use of org.springframework.format.support.FormattingConversionService in project spring-boot by spring-projects.
the class WebFluxAutoConfigurationTests method defaultDateTimeFormat.
@Test
void defaultDateTimeFormat() {
this.contextRunner.run((context) -> {
FormattingConversionService conversionService = context.getBean(FormattingConversionService.class);
LocalDateTime dateTime = LocalDateTime.of(2020, 4, 28, 11, 43, 10);
assertThat(conversionService.convert(dateTime, String.class)).isEqualTo(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).format(dateTime));
});
}
use of org.springframework.format.support.FormattingConversionService in project spring-boot by spring-projects.
the class ConversionServiceArguments method with.
static Stream<? extends Arguments> with(Consumer<FormattingConversionService> initializer) {
FormattingConversionService withoutDefaults = new FormattingConversionService();
initializer.accept(withoutDefaults);
return Stream.of(Arguments.of(new NamedConversionService(withoutDefaults, "Without defaults conversion service")), Arguments.of(new NamedConversionService(new ApplicationConversionService(), "Application conversion service")));
}
Aggregations