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);
springboot格式化时间的更多相关文章
- 3种 Springboot 全局时间格式化方式,别再写重复代码了
本文收录在个人博客:www.chengxy-nds.top,技术资料共享,同进步 时间格式化在项目中使用频率是非常高的,当我们的 API 接口返回结果,需要对其中某一个 date 字段属性进行特殊的格 ...
- SpringBoot中时间格式化的5种方法!
在我们日常工作中,时间格式化是一件经常遇到的事儿,所以本文我们就来盘点一下 Spring Boot 中时间格式化的几种方法. 时间问题演示 为了方便演示,我写了一个简单 Spring Boot 项 ...
- SpringBoot全局时间转换器
SpringBoot全局时间转换器 日常开发中,接收时间类型参数处处可见,但是针对不同的接口.往往需要的时间类型不一致 @DateTimeFormat(pattern = "yyyy-MM- ...
- 04 Springboot 格式化LocalDateTime
Springboot 格式化LocalDateTime 我们知道在springboot中有默认的json解析器,Spring Boot 中默认使用的 Json 解析技术框架是 jackson.我们点开 ...
- WP7、WP8 格式化时间为距当前多少时间
方法一: 使用 toolkit的 RelativeTimeConverter,使用方式 <phone:PhoneApplicationPage.Resources> <toolkit ...
- golang 格式化时间为字符串
package main import ( "fmt" "reflect" "time" ) func main() { //格式化字符串为 ...
- php友好格式化时间
php格式化时间显示 function toTime($time) {//$time必须为时间戳 $rtime = date("Y-m-d H:i",$time); $htime ...
- java 格式化时间
java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); form ...
- 封装insertAfter、addClass、格式化时间
insertAfter,在JS节点操作中,并没有insertAfter方法,因此需要重新封装 function insertAfter(newEle,targetNode) { var oParent ...
随机推荐
- pytorch的函数中的group参数的作用
1.当设置group=1时: conv = nn.Conv2d(in_channels=, out_channels=, kernel_size=, groups=) conv.weight.data ...
- MyCP.java蓝墨云班课
题目要求: 编写MyCP.java 实现类似Linux下cp XXX1 XXX2的功能,要求MyCP支持两个参数: java MyCP -tx XXX1.txt XXX2.bin 用来把文本文件(内容 ...
- spring boot 打包war
@SpringBootApplication public class AesApplication extends SpringBootServletInitializer { public sta ...
- 微信中如何做到访问app的下载链接时直接跳到默认浏览器去执行下载
在我们使用微信营销的时候,很容易碰到H5链接在微信内无法打开或在微信内无法打开app下载页的情况.通常这种情况微信会给个提示 “已停止访问该网址” ,那么导致这个情况的因素有哪些呢,主要有以下四点 1 ...
- Boolean 类型转换
原文作者: louis 原文链接: http://louiszhai.github.io/2015/12/11/js.boolean/ 语法 众所周知, JavaScript有五个基本的值类型:num ...
- vue项目上传Github预览
最近在用Vue仿写cnode社区,想要上传到github,并通过Github pages预览,在这个过程中遇到了一些问题,因此写个笔记,以便查阅. 完成Vue项目以后,在上传到github之前,需要修 ...
- Linux跑脚本用sh和./有什么区别?(转)
sh是一个shell.运行sh a.sh,表示我使用sh来解释这个脚本:如果我直接运行./a.sh,首先你会查找脚本第一行是否指定了解释器,如果没指定,那么就用当前系统默认的shell(大多数linu ...
- python一(字符串,字典)
list操作 name = ['小王','小米','小张','王强','张三','李四'] name.append('黄霑')#添加元素在最后一个 name.insert(,'王五')#指定下标插入元 ...
- QComboBox使用方法,QComboBox详解
fromComboBox = QComboBox() 添加一个 combobox fromComboBox.addItem(rates) 添加一个下拉选项 fromComboBox.addItems( ...
- OrCAD原理图中怎么导出FPGA的引脚分配
流程 (1)选择tool下的export FPGA: (2)选择厂商,选择器件型号.选择生成文件类型. 以上.