JodaTime LocalDate format in SpringMvc JSON using formatting

I have a problem with my Spring application.
How can I format LocalDate in JSON ...
The problem is that when I send JSON, I need to send a number, but when Spring will generate JSON, I:

 "data": { "weekyear": 1970, "weekOfWeekyear": 1, "chronology": { "zone": { "fixed": true, "id": "UTC" } }, "monthOfYear": 1, "yearOfEra": 1970, ...and a lot more 

I have a field annotated with DateTimeFormat as:

 @DateTimeFormat(pattern="dd/MM/yyyy") private LocalDate data; 

And also configured the format service in servlet-context.xml :

 <beans:bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"> </beans:bean> 

But this alone does not work, what am I missing for customization?

+4
source share

Source: https://habr.com/ru/post/1481899/


All Articles