springmvc在表单提交接收date类型参数的时候会报错:Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'actionDate' 一.利用spring的DateTimeFormat注解 让springmvc提交表单时正确的接收date类型参数,主要分以下3个步骤: 1.在需要由string转Date的字段上加上DateTimeFormat注解,代码如
Swagger要传送对象作为参数,只需添加@ModelAttribute或@RequestBody @RestController @RequestMapping("/api/json/resourceHome") @Api(value="/api/json/resourceHome",description="资源客户端首页API") public class ResourceClientHomeController { @RequestMap
用Timestamp来记录日期时间还是很方便的,但有时候显示的时候是不需要小数位后面的毫秒的,这样就需要在转换为String时重新定义格式. Timestamp转化为String: SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒 Timestamp now = new Timestamp(System.currentTimeMillis());//获取系统当前时