当前位置:网站首页>@The difference and use of jsonformat and @datetimeformat
@The difference and use of jsonformat and @datetimeformat
2022-07-26 10:47:00 【Eric-x】
@DatetimeFormat Yes, it will String convert to Date, Generally, it is used when the foreground transmits values to the background
import org.springframework.format.annotation.DateTimeFormat;
/** * When transferring from the front desk to the back desk , Strings are automatically encapsulated into dates */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date birth;
@JsonFormat(pattern=”yyyy-MM-dd”) take Date convert to String Generally, when the background transmits the value to the foreground
import com.fasterxml.jackson.annotation.JsonFormat;
/** * When the backstage returns to the front desk , Date auto format */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date birth;
Be careful
@JsonFormat It can not only complete the type conversion of background to foreground parameter transfer , It can also realize the type conversion from foreground to background .
When content-type by application/json when , priority of use @JsonFormat Of pattern Do type conversion . Not used @DateTimeFormat Do type conversion .
@JsonFormat The function of annotation is to complete json String to java Object conversion , Independent of the direction of parameter passing .
then :@DateTimeFormat and @JsonFormat Respectively belong to Spring and Jackson
Reference link :https://www.cnblogs.com/wq-9/articles/12000799.html
边栏推荐
- RT thread learning notes (V) -- edit, download and debug programs
- Bigdecimal的加减乘除、比较大小、向上向下取整 和 Bigdecimal的集合累加、判断BigDecimal是否有小数
- [leetcode daily question 2021/2/14]765. Lovers hold hands
- Happens-Before原则深入解读
- 智能合约dapp系统开发流程技术
- 用两个栈实现队列
- $router和$route的区别
- 剑指Offer(二十一):栈的压入、弹出序列
- 鹏哥C语言第七节课总结
- RT thread learning notes (VI) -- start the elmfat file system based on SPI flash (Part 1)
猜你喜欢
![[leetcode daily question 2021/2/14]765. Lovers hold hands](/img/be/8639a05c733638bf0b3fdeb11abccf.png)
[leetcode daily question 2021/2/14]765. Lovers hold hands

Sql Server 数据库之数据类型

为什么需要自动化测试?软件测试师带你测评不同软件测试工具

工厂模式详解

Issue 8: cloud native -- how should college students learn in the workplace

在altium designer中禁用USBJATG

0x00007FFD977C04A8 (Qt5Sqld.dll)处(位于 a.exe 中)引发的异常: 0xC0000005: 读取位置 0x0000000000000010 时发生访问冲突

RT-Thread 学习笔记(六)--- 开启基于SPI Flash的elmfat文件系统(上)

很多人都不清楚自己找的是Kanban软件还是看板软件

如何组装一个注册中心?
随机推荐
剑指Offer(五):用两个栈实现队列
鹏哥C语言第四课(3)
[leetcode daily question 2021/4/29]403. Frogs cross the river
MySQL quicklearn-2021-09-01
剑指Offer(八):跳台阶
WinPcap packet capturing function pcap_ Loop (), stop the problem
Sword finger offer (53): a string representing a numeric value
MySQL quick learning notes-2021-08-31
Kali view IP address
1748.唯一元素的和
在神州IV开发板上为STemWin 5.22加入触屏驱动
12 don't forget every component when copying an object
访问权限——private,public,protected
面试过程中,面试官是如何考察Rust工程师的水平?
Halcon模板匹配之Shape
display-inline+calc实现左中右布局,中间自适应
c结构体中定义的成员指针赋值与结构体指针作为成员函数参数的使用
MultipartFil转为File
RT thread learning notes (VI) -- start the elmfat file system based on SPI flash (Part 1)
RT-Thread 学习笔记(七)---开启基于SPI Flash的elmfat文件系统(中)