Date type data in springboot as a parameter error in postman interface test

1. Error description

Encountered a problem, in springboot, the backend interface parameter is date type, use postman to test the interface, the parameter format is: '2018-6-24 21:39:58', an error indicates that the parameter passed is a string, The date to be transmitted is date.

2. Solution

Cause: The error means that the String type cannot be converted to the Date type. The real error is that the parameter format is incorrect.

Solution: The parameter format was written incorrectly and amended to: 2018/7/7 11:11:00. Just write the format as yyyy / MM / dd 00:00:00, springboot can be automatically converted to Date type objects.

3. The difference between C # and JAVA

I wrote a simple interface in C #, use '2018/7/7 11:11:00' to request no problem, and then use '2018-6-24 21:39:58' request, found that there is no problem, single After step-by-step debugging, it was found that although the parameter format in postman is '2018-6-24 21:39:58', the interface actually received '2018/6/24 21:39:58'.

From this process, it can be compared that under the vs platform, using C # language, the time format requirements are not so strict, but at the same time he will convert the received data format, and Java will report an error because of this format.

 

Published 30 original articles · Like1 · Visits1158

Guess you like

Origin blog.csdn.net/chunchunlaila/article/details/105588730