Home > Back-end >  In a springboot project how to turn the json data into a date data type to the backend
In a springboot project how to turn the json data into a date data type to the backend

Time:12-05

My watch is a field of the data type for the date format, I in the JSP & lt; Input type="date" & gt; Reported data to the control layer, exception to Failed to convert the property value of type 'Java. Lang. String' to the required type 'Java. Util. Date' for the property
Could you tell me what should I speak from the front the json data into a date data format to the control layer

CodePudding user response:

Change the control layer is also answered the String parameter, wrote the model to date

CodePudding user response:

You can change a train of thought, because of the general control layer receives the parameters are of type string, you can receive in the background to the value of time, through the Java string transfer date, in the background of transformation, and then apply transformation after the date of the type of data in your subsequent logically
You can baidu "Java string transfer date"
May code is as follows:
SimpleDateFormat SimpleDateFormat=new SimpleDateFormat (" yyyy - MM - dd HH: MM: ss ");
String dateStr="2019-01-03 10:59:27";
The Date the Date=simpleDateFormat. Parse (dateStr);

This date is the data you want
  • Related