The rear end of the return type, Date type defined directly, add this note directly converted to the Date format type to a custom front end
TestDateOutput {class
@JsonFormat (pattern = "the MM-dd-YYYY")
Private Create a Date;
}
Note: the non-spring-boot program necessary to introduce a dependency, the default spring-boot program has been introduced
<dependency>
<the groupId> com.fasterxml.jackson.core </ the groupId>
<the artifactId> Jackson-Annotations </ the artifactId>
<Version> 2.9.0 </ Version>
</ dependency>
two: java accept front rear fixed date type string, date type directly converted into
a rear end of the data at the time of receiving the front end, the front end of the string pass back fixed date format, by arranging the rear end of this annotation, the data can be directly converted to type date
class TestDateIntput{
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date create;
}
原文链接:https://blog.csdn.net/java_zhangshuai/article/details/95951400