使用@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);

springboot格式化时间的更多相关文章

  1. 3种 Springboot 全局时间格式化方式,别再写重复代码了

    本文收录在个人博客:www.chengxy-nds.top,技术资料共享,同进步 时间格式化在项目中使用频率是非常高的,当我们的 API 接口返回结果,需要对其中某一个 date 字段属性进行特殊的格 ...

  2. SpringBoot中时间格式化的5种方法!

    在我们日常工作中,时间格式化是一件经常遇到的事儿,所以本文我们就来盘点一下 Spring Boot 中时间格式化的几种方法. ​ 时间问题演示 为了方便演示,我写了一个简单 Spring Boot 项 ...

  3. SpringBoot全局时间转换器

    SpringBoot全局时间转换器 日常开发中,接收时间类型参数处处可见,但是针对不同的接口.往往需要的时间类型不一致 @DateTimeFormat(pattern = "yyyy-MM- ...

  4. 04 Springboot 格式化LocalDateTime

    Springboot 格式化LocalDateTime 我们知道在springboot中有默认的json解析器,Spring Boot 中默认使用的 Json 解析技术框架是 jackson.我们点开 ...

  5. WP7、WP8 格式化时间为距当前多少时间

    方法一: 使用 toolkit的 RelativeTimeConverter,使用方式 <phone:PhoneApplicationPage.Resources> <toolkit ...

  6. golang 格式化时间为字符串

    package main import ( "fmt" "reflect" "time" ) func main() { //格式化字符串为 ...

  7. php友好格式化时间

    php格式化时间显示 function toTime($time) {//$time必须为时间戳 $rtime = date("Y-m-d H:i",$time); $htime ...

  8. java 格式化时间

    java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); form ...

  9. 封装insertAfter、addClass、格式化时间

    insertAfter,在JS节点操作中,并没有insertAfter方法,因此需要重新封装 function insertAfter(newEle,targetNode) { var oParent ...

随机推荐

  1. ssrfme 复现

    这道题搞了我很长时间,主要太菜了,开始复现吧 <?php     $sandbox = "sandbox/" . md5("orange" . $_SER ...

  2. Mongo C# Driver 聚合使用---深入浅出

    聚合查询结构体系 ​ 我们都知道Mongo中聚合是由$match,$project等聚合项组成,所以在C# Driver中具有两种类型:聚合管道(PipelineDefinition)和聚合管道项(I ...

  3. Git使用(积累一些常用的命令)

    1. 取消某一次合并  git merge --abort 可以参考的教程:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248 ...

  4. F2 - Spanning Tree with One Fixed Degree - 并查集+DFS

    这道题还是非常有意思的,题意很简单,就是给定一个图,和图上的双向边,要求1号节点的度(连接边的条数)等于K,求这棵树的生成树. 我们首先要解决,如何让1号节点的度时为k的呢???而且求的是生成树,意思 ...

  5. OSI七层模型的每一层都有哪些协议

    TCP/IP: 数据链路层:ARP,RARP 网络层: IP,ICMP,IGMP 传输层:TCP ,UDP,UGP 应用层:Telnet,FTP,SMTP,SNMP. OSI: 物理层:EIA/TIA ...

  6. Linux(Ubuntu)使用日记------部署JavaWeb项目到服务器

    0.前言 本博文内容是建立在你可以通过SSH连接到远程服务器的基础上的,如果你还没有用SSH连接到远程服务器,请参考此文(腾讯云服务器): http://www.cnblogs.com/hwtblog ...

  7. C#中字符串转日期类型

    1,yyyyMMdd DateTime date = DateTime.ParseExact(", "yyyyMMdd", System.Globalization.Cu ...

  8. 为什么qt成为c++界面编程的第一选择

    为什么qt成为c++界面编程的第一选择 一.前言 为什么现在QT越来越成为界面编程的第一选择,笔者从事qt界面编程已经有接近8年,在这之前我做C++界面都是基于MFC,也做过5年左右.当时为什么会从M ...

  9. codeforces510D

    Fox And Jumping CodeForces - 510D Fox Ciel is playing a game. In this game there is an infinite long ...

  10. code runner 使用教程

    https://zhuanlan.zhihu.com/p/54861567 其中解决无法在编辑器中编辑问题(编辑器只读) 只需要把Code-runner: Run In Terminal true(打 ...