Jackson/fastjson Serialization/deserialization:
By default, Jackson/fastjson serializes the Java date/timestamp type to a timestamp, which is the number of milliseconds since 0 o'clock on January 1, 1970. If you want to display a user-friendly representation:
Jackson can:
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); Objectmapper.setdateformat (SDF)
Or:
@JsonFormat (locale= "zh", timezone= "gmt+8", pattern= "Yyyy-mm-dd HH:mm:ss")
Fastjson can:
@JSONField (format="Yyyy-mm-dd HH:mm:ss")
Or:
The first method:
Json. Deffault_date_format = "YYYY-MM-DD";
String str = json.tojsonstring (User,serializerfeature.writedateusedateformat);
The second method:
JSON.toJSONStringWithDateFormat(date, "yyyy-MM-dd HH:mm:ss.SSS")
=================
Timestamp datetime type corresponding to MySQL
Timestamp corresponds to MySQL's timestamp type date will correspond to MySQL's date type <result column="Modified_date" Jdbctype="TIMESTAMP" property="modified_date" javatype=" java.sql.Timestamp"/>
<result column="date" jdbctype="date" property="date" javatype=" Java.util.Date " />
Fields indicated: #{modified_date,jdbctype=timestamp}, #{date,jdbctype=date}
For specific reference: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-type-conversions.html
Jackson/fastjson, MyBatis, MySQL Date/datatime/timestamp, Java date/timestamp Relationship detailed