使用@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. boost学习目录

    Boost之数值转换lexical_cast https://www.cnblogs.com/TianFang/archive/2013/02/05/2892506.html Boost之字符串算法s ...

  2. video标签,在移动端获取第一帧作为展示

    写在前面 video标签,获取第一帧作为poster.网上能找着很多案例,很容易实现,在pc端 效果明显.但是在移动端,这些实现方式并不能起作用.原因是 移动端 对video标签的限制,许多video ...

  3. Photoshop快速给美女人像换头发

    今天给大家带来的教程是应用PS来抠出人物图片的发丝和修改头发的颜色. OK开始今天的教程 1.将素材文件拖拽进PS,CTRL+J复制一层. 2.应用快速选择工具大致的将头发部分选区出来,不需要太过仔细 ...

  4. Net包管理NuGet(3)搭建私服及引用私服的包

    1,打开vs创建项目(ASP.NET WEB空项目)假设命名为MyNuGet 空项目解决方案如图 2,右键引用>管理NuGet程序包>切到浏览搜索NuGet.Server然后安装(3.1. ...

  5. [转帖]Windows Server 2016各种版本介绍

    Windows Server 2016各种版本介绍 http://www.5sharing.com/js/zx/872.html windows server的版本 时间:2018-10-06 10: ...

  6. 【MongoDB异常】Exception authenticating MongoCredential解决方法

    我们通过ideal编辑器编辑 springboot时候,出现这个错误: com.mongodb.MongoSecurityException: Exception authenticating Mon ...

  7. pc端常規頁面實現

    https://www.cnblogs.com/adc8868/p/5996885.html https://blog.csdn.net/chose_DoIt/article/details/8042 ...

  8. Leetcode 4

    Array Easy 1. 268. Missing Number 先对数组求和,用 0 ~ n本该有的和减去当前sum得到缺失的数字. class Solution { public int mis ...

  9. Java技术栈思维导图

    Java技术栈思维导图 Java IO流体系 设计模式

  10. ubuntu apt update failed to fetch

    When I do command sudo apt update, always get belowing errors: Err:1 http://archive.ubuntu.com/ubunt ...