Are the personal understanding of SPRINGMVC;
@DateTimeFormat (pattern= "Yyyy-mm-dd HH:mm:ss")
@JsonFormat (pattern= "Yyyy-mm-dd HH:mm:ss", timezone = "gmt+8")
1 parsing/formatting of the field level
Add @DateTimeFormat (pattern= "Yyyy-mm-dd HH:mm:ss") to the attribute or get method of the entity class.
The date string in the form is correctly converted to the date type. There are also @numberformat annotations,
Detailed
@Number: Define number-related parsing/formatting metadata (common style, currency style, percent style) with the following parameters:
Style: Used to specify style type, including three kinds: Style.number (Universal Style) style.currency (currency style) Style.percent (Percent style), default style.number;
Pattern: Custom style, such as patter= "#,###";
@DateTimeFormat: Define date-related parsing/formatting metadata with the following parameters:
Pattern: Specifies a pattern for parsing/formatting field data, such as "Yyyy-mm-dd HH:mm:ss"
ISO: Specifies the ISO mode for parsing/formatting field data,
Includes four types: Iso.none (not used)
Iso. DATE (YYYY-MM-DD)
Iso. Time (HH:MM:SS. SSSZ)
Iso. Date_time (Yyyy-mm-dd hh:mm:ss. SSSZ),
Default Iso.none;
2
@JsonFormat annotation, after it is configured on the Get method of the date type,
Jackson will convert the date type in the configured format without customizing the converter class
3
Spring can return objects, and the object is converted to JSON data in a format returned;
Of course you can also use Response.getwriter (). Write to return the format of the JSON data.
Three Jackson bags: Jackson-core.jar, jackson-databind.jar,j Ackson-annotations.jar