When using JSONSerializer.toJSON to return the JSON value, the time is divided into details. Look at the figure in detail.

refers to an example. After background processing, I return the value as follows:

JSON json = JSONSerializer.toJSON(new JsonResult<ResumeVO>(0, "!", resumeVO));
return json.toString();

in this way, if the returned entity contains a value of type Date or Timestamp, it will be displayed at the front end as follows:

"birthday": {
                "date": 26,
                "hours": 0,
                "seconds": 0,
                "month": 5,
                "timezoneOffset": -480,
                "year": 96,
                "minutes": 0,
                "time": 835718400000,
                "day": 3
            }

has anyone ever used this tool class, ah, why is it still displayed in the form of yyyy-MM-dd?
(@ JsonFormat is useless. Changing it to a string type is useful, but it won"t take a lot of effort to change it now.)

Mar.28,2021

@ JsonFormat is solvable and should be the problem with your code. You can also use controls to format the display of this field at the front end.


generally speaking, if the backend json passes the time, it is better to send you such a timestamp, and then change it from the previous paragraph to the time string you want to display.
there is a similar problem. You can take a look at . Why does the backend give the foreground Date a time stamp, while the foreground to the background is a time string directly?


if you are spring boot, please take a look at this example item: https://github.com/chanjarste.


I have met before, and I found the formatting time of the end js code on the Internet.

    //Date Date String  
    //(M)(d)(h)(m)(s)(q)  1-2    
    //(y) 1-4 (S) 1 ( 1-3 )   
    Date.prototype.Format = function (fmt) { 
        var o = {  
            "M+": this.getMonth() + 1, //   
            "d+": this.getDate(), //   
            "H+": this.getHours(), //   
            "m+": this.getMinutes(), //   
            "s+": this.getSeconds(), //   
            "q+": Math.floor((this.getMonth() + 3) / 3), //   
            "S": this.getMilliseconds() //   
        };  
        if (/(y+)/.test(fmt)) 
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));  
        for (var k in o)  
            if (new RegExp("(" + k + ")").test(fmt))
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));  
        return fmt;  
    }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e5e0-2c3ff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e5e0-2c3ff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?