使用mybatis查询返回的结果时间只显示日期,不显示时分秒,返回的是resultType="hashmap"
问题描述:
使用mybatis查询返回的结果时间只显示日期,不显示时分秒,返回的是resultType="hashmap",我没有用映射,请问这个该怎么解决,下面是代码
select * from operation_record a join login b where a.loginName=b.loginName
and b.name like '%${name}%'
and a.operation_time between '${startDateTime}' and '${endDateTime}' limit ${page}, 20
答
把* 换成每个字段,把时间字段格式化一下,DATE_FORMAT(你的字段,'%Y-%m-%d %H:%i:%s')
答
1,你数据库的字段带时分秒了吗
2,你指定一下接收的字段的,时间格式
@JSONField(format="yyyy-MM-dd HH:mm:ss")
public Date date;
或者
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
public Date date;
这两个都可以
答
在result中设置对应字段的jdbcType = "TIMESTAMP",然后resultType设置成对应的ResultMap