The front-end passes the date type to the back-end, but the back-end cannot receive data
Processing method 1: convert the date to a string and send it to the background, and convert the background string to a date and then assign it
public class DateConvert { public static void main(String[] args) { Date date = null; String str="2018-04-24 00:00:00"; SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { date=sdf.parse(str);//String 转 DATE } catch (ParseException e) { e.printStackTrace (); } System.out.println(date); //DATE转String str=sdf.format(date); System.out.println(str); } }
result:
Tue Apr 24 00:00:00 CST 2018 2018-04-24 00:00:00