Trying to convert date from a date to calendar. Using springBoot. I was not clear about the true cause of the exception. Could someone 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;
}
}
No 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]