1
Trying to convert date from date to date. Using springBoot. I didn’t have clarity about the true cause of the exception. Someone could help?
@SpringBootApplication
public class Boot
{
public static void main(String[] args)
{
SpringApplication.run(Boot.class, args);
}
@Bean
public FormattingConversionService mvcConversionService() {
DefaultFormattingConversionService conversionSeervice = new DefaultFormattingConversionService(true);
DateFormatterRegistrar registrar = new DateFormatterRegistrar();
registrar.setFormatter(new DateFormatter("yyyy-MM-dd"));
registrar.registerFormatters(conversionSeervice);
return conversionSeervice;
}
}
in the Model
@DateTimeFormat(tried with and without pattern)
private Calendar releaseDate;
in the JSP
<div>
<label for="releaseDate">Data de Lançamento</label>
<form:input path="releaseDate" type="date" id="releaseDate"/>
<form:errors path="releaseDate"/>
</div>
Exception:
Failed to Convert Property value of type java.lang.String to required type java.util.Calendar for Property releaseDate; nested Exception is org.springframework.core.convert.Conversionfailedexception: Failed to Convert from type [java.lang.String] to type [@org.springframework.format.annotation.Datetimeformat java.util.Calendar] for value 2017-12-06; nested Exception is java.lang.Illegalargumentexception: Parse Attempt failed for value [2017-12-06]
How’s your
DateFormatterRegistrar
?– Gustavo Cinque
what you want to know about him?
– Rafael Perracini
I want to know how you convert the date.
– Gustavo Cinque
He was being written by Spring. I disabled the override, but now I’m with another exception I used public Static void main(String[] args) { new Springapplicationbuilder(Boot.class) . initializers((Genericapplicationcontext c) -> c.setAllowBeanDefinitionOverriding(false) ) . run(args); }
– Rafael Perracini
but now I’m with another exception org.springframework.Beans.factory.Beandefinitionstoreexception: Invalid bean Definition with name 'mvcConversionService' defined in class path Resource [org/springframework/boot/autoconfigure/web/Webmvcautoconfiguration$Enablewebmvcconfiguration.class]: Cannot Register bean Definition, which is logical because I blocked the override
– Rafael Perracini