- Add a comment above the field you want to convert
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
private Date startTime;
-
Import maven joda-time dependencies for @DateTimeFormat using add configuration or manually add joda-time jar (especially important).
-
Spring-web add @DateTimeFormat using configuration add:
<mvc:annotation-driven></mvc:annotation-driven>
@DateTimeFormat realizes the Date conversion of the page passed to the control layer Controller, and will not affect other data queries.