Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The date is one day less when Jackson returns JSON

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

After testing, it is found that when an object is converted to JSON, the value returned by the date type is always 1 less than the value in the database.

For example, if the date of the database is 2017-12-12, it will become 2017-12-1 when it is transferred to JSON. Solution 1:

Use @ JsonFormat (pattern= "yyyy-MM-dd", timezone= "GMT+8") br/ > solution 1 in the get method of the object POJO:

Use @ JsonFormat (pattern= "yyyy-MM-dd", timezone= "GMT+8") in the get method of the object POJO

/ * timeZone= "GMT+8" plus time zone * /

@ JsonFormat (pattern = "yyyy-MM-dd", timezone= "GMT+8")

Public Date getShenqrq () {

Return shenqrq

}

Public void setShenqrq (Date shenqrq) {

This.shenqrq = shenqrq

}

Solution 2:

NON_NULL

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report