zoukankan      html  css  js  c++  java
  • springboot格式化时间

    使用@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);
  • 相关阅读:
    配置并学习微信JS-SDK(1)
    在 Sublime Text 3 中运行 PHP
    apache-配置虚拟主机
    mysql-积累管理sql语句
    博客园-推荐发博客工具的安装配置
    注释多行文本
    nargin
    Sublime Text
    The MATLAB Profiler
    Fig723.asy
  • 原文地址:https://www.cnblogs.com/AnonymouL/p/9512273.html
Copyright © 2011-2022 走看看