使用@RestController注解,返回的java对象中若含有date类型的属性,则默认输出为TIMESTAMP时间戳格式,可以在配置文件加入下面配置
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8

 


也可以在mybatis查询的时候直接使用mysql函数"DATE_FORMAT"直接格式化,如下
@Select({
        "SELECT id,title,DATE_FORMAT(create_date,'%Y-%c-%d') create_date",
        "FROM zx_news_structure",
        "WHERE is_deleted=0 and push_type=#{pushType}",
        "order by push_topping_date desc,show_date desc limit #{limitSize}"
})
@Results({
        @Result(column="id", property="id", jdbcType= JdbcType.INTEGER),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_date", property="createTime", jdbcType=JdbcType.VARCHAR),

})
List<NewsVo> getNewsList(@Param("limitSize") int limitSize, @Param("pushType") int pushType);

 

相关文章:

  • 2021-09-28
  • 2021-06-12
猜你喜欢
  • 2021-12-22
  • 2021-12-24
  • 2022-01-08
  • 2022-02-17
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
相关资源
相似解决方案