bootstrap中的datetime-local后台接受处理

通过引用bootstrap中的datetime-local可以快速进行前端日期时间选择的搭建,但是这种时间类型中间会产生一个T,后台接受后与实体类中的 Date不一致,这就需要我们处理 一把。上代码:

form引用datetime-local:

<input type="datetime-local" name="examinfoStarttime" id="exampleInput1" value=""/>

后端处理:

@RequestMapping(value = "releaseExaminfo") 
   public ModelAndView releaseExaminfo(ModelAndView mav,examinfoTime){
			    Examinfo examinfo = new Examinfo();
			    SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	            Date time = null;
	            try {
					String str=":00";
				    time = sdf.parse(examinfoTime.replace("T"," ")+str);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	            examinfo.setExaminfoTime(time);
	            if(examinfoBiz.releaseExaminfo(examinfo) != -1){
			       mav = (new ModelAndView(new RedirectView("allExaminfo.do")));
		       } 
		           return mav;
		       }

其实 就是去了个T。以后别出错(找错心累)在这里记录一下。     火狐不支持datetime-local,可以用别的。

猜你喜欢

转载自blog.csdn.net/qq_37333151/article/details/84848329