Spring Boot后端与Angular前端进行timestamp的交互

后端使用java.sql.Timestamp

后端vo字段类型使用前端

import java.sql.Timestamp;

Mapper能够为字段加上属性jdbcType="TIMESTAMP" 也能够不加java

<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>

Angular前端vo

不管后端使用什么类型进行时间戳转换,都须要前端将Date转换成时间戳的形式(number)sql

java.sql.Timestamp
java.sql.Date
java.util.Date

前端字段后端

startTime: number;

vo赋值时使用app

this.testVo.startTime = Date.parse(new Date().toString())

从后端获取数据后须要在前端进行转换this

new Date(this.testVo.startTime)

我的博客 蜗牛code

相关文章
相关标签/搜索