Springboot配置时间格式
方法一:
可以在apllication.property加入下面配置就可以
#时间戳统一转换
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
方法二:
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date createdDate;
@JsonFormat(timezone = "GMT+8", pattern = "yyyyMMddHHmmss")
private Date createTime;
引入依赖:
<!--使用JsonFormat注解-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.0</version>
</dependency>
<!--使用DataFormat注解-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.1.5.RELEASE</version>
<scope>compile</scope>
</dependency>
方法三:
可以在apllication.yml加入下面配置就可以
#时间戳统一转换
spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
注意: @JsonIgnoreProperties此注解是类注解,作用是json序列化时将java bean中的一些属性忽略掉,序列化和反序列化都受影响。 @JsonIgnoreProperties(value = { "word" }) 。 @JsonIgnore此注解用于属性或者方法上(最好是属性上),作用和上面的@JsonIgnoreProperties一样。 @JsonSerialize此注解用于属性或者getter方法上,用于在序列化时嵌入我们自定义的代码,比如序列化一个double时在其后面限制两位小数点。 @JsonSerialize(using = CustomDoubleSerialize.class) @JsonDeserialize此注解用于属性或者setter方法上。
用于在反序列化时可以嵌入我们自定义的代码,类似于上面的 @JsonSerialize @JsonDeserialize(using = CustomDateDeserialize.class)
参考:https://blog.csdn.net/qq_32447301/article/details/81712266
方法一:
可以在apllication.property加入下面配置就可以
#时间戳统一转换
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
- 1
- 2
- 3
方法二:
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date createdDate;
- 1
- 2
- 3
@JsonFormat(timezone = "GMT+8", pattern = "yyyyMMddHHmmss")
private Date createTime;
- 1
- 2
方法三:
可以在apllication.yml加入下面配置就可以
#时间戳统一转换
spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
Springboot配置时间格式的更多相关文章
- jackson springboot配置时间格式
yml文件中这样进行配置 spring: jackson: date-format: yyyy-MM-dd HH:mm:ss spring.jackson.date-format指定日期格式,比如yy ...
- 调度 Quartz 时间格式配置
1. CronTrigger时间格式配置说明 CronTrigger配置格式: 格式: [秒] [分] [小时] [日] [月] [周] [年]
- Confluence 6 配置时间和日期格式
你可以修改你 Confluence 为用户显示的时期和时间格式.设置的句法使用的是 SimpleDateFormat class,请参考 Java SimpleDateFormat 文档中的内容来设置 ...
- jsp采用数据库连接池的方法获取数据库时间戳context.xml配置,jsp页面把时间格式化成自己需要的格式
<?xml version="1.0" encoding="UTF-8"?> <!-- 数据库连接池配置文件 --> <Conte ...
- .Net Core 配置之long类型 前端精度丢失和时间格式设置
在很多项目中,都采用的前后端分离的方式进行开发,经常遇到后台的long精度的数据到前端丢失不准确,显示效果为long类型(19位)的后几位为000,此时需要对long的字段进行设置,改变默认的返回类型 ...
- SpringBoot配置属性之Server
SpringBoot配置属性系列 SpringBoot配置属性之MVC SpringBoot配置属性之Server SpringBoot配置属性之DataSource SpringBoot配置属性之N ...
- springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息
1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...
- SpringBoot配置(2) slf4j&logback
SpringBoot配置(2) slf4j&logback 一.SpringBoot的日志使用 全局常规设置(格式.路径.级别) SpringBoot能自动适配所有的日志,而且底层使用slf4 ...
- SpringBoot配置Aop笔记【例子】
众所周知,spring最核心的两个功能是aop和ioc,即面向切面,控制反转.这里我们探讨一下如何使用spring aop. 1.何为aop aop全称Aspect Oriented Programm ...
随机推荐
- HDU 1079 Calendar Game (博弈)
Calendar Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- mysql 删除用户
select * FROM sys_user_role where user_id in( SELECT id FROM sys_user where login_name='17600311226' ...
- curl 出现错误的调试方法
private function httpGet($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, tru ...
- awk统计文件大小
在Linux系统中,经常会遇到某个目录下文件很多,要统计这些文件的空间大小.可以采用awk来实现.如下是实现这个功能的例子. vim sum.sh #!/bin/bash# sum.shcd //ba ...
- Event Recommendation Engine Challenge分步解析第四步
一.请知晓 本文是基于: Event Recommendation Engine Challenge分步解析第一步 Event Recommendation Engine Challenge分步解析第 ...
- Matlab2017A破解版安装详细图文教程(附破解补丁) 64位
摘录网址:http://www.jb51.net/softjc/543170.html MATLAB2017a安装教程: 1.下载并解压本站提供的MATLAB2017a破解版安装包,载入右键解压或者使 ...
- OPCServer:使用Matrikon OPC Server Simulation
实验用模拟OPCServer 旧版(50M):Matrikon OPC Server Simulation(v1.5.0.0),百度网盘,密码: mcur 新版(157M):Matrikon OPC ...
- Python实现工厂模式
from abc import ABCMeta, abstractmethod from enum import Enum class Person(metaclass=ABCMeta): @abst ...
- 30. Spring Boot ActiveMQ
1.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...
- GCC编译器原理(二)------编译原理一:ELF文件(1)
二.ELF 文件介绍 2.1 可执行文件格式综述 相对于其它文件类型,可执行文件可能是一个操作系统中最重要的文件类型,因为它们是完成操作的真正执行者.可执行文件的大小.运行速度.资源占用情况以及可扩展 ...