mybaits长整形long与时间戳mysql timestamp数据转换

借用MySQL函数实现

  1. long 转 timestamp:FROM_UNIXTIME(long, [format])

示例:限制10位时间戳,13位不可以
FROM_UNIXTIME(1249488000)

FROM_UNIXTIME(1249488000, ‘%Y-%M-%d %H:%m:%s‘)

整合到mybatis leaveTime为long型

<insert id="insertLiveOrder" parameterType="map">
        insert into
        reserve_record(orderId, uname, phoneNumber, roomType, reserveTime, preFee, status, startTime, endTime)
        values (#{orderId}, #{uname}, #{phoneNumber}, #{roomType}, NOW(), #{preFee}, 0,
        FROM_UNIXTIME(#{signTime}), FROM_UNIXTIME(#{leaveTime}))
</insert>
  1. timestamp转long:UNIX_TIMESTAMP

示例:

UNIX_TIMESTAMP(‘2020-07-11‘)

mybaits长整形long与时间戳mysql timestamp数据转换

上一篇:makefile 里的vpath


下一篇:PostgreSQL配置参数详解(个人理解)