About the problem of javadate data returning to the front-end variable numbers

Source: Internet
Author: User

Do not know why, the front-end display all the data items are not wrong, only the time that one is very strange, is a series of numbers, and this number in the database can not find ...

Then I debug the backend from the service to the controller, and found that the data are not wrong, take is time ah.

Baidu later know that the original back in the back of the JSON data, with its own serialization mechanism will turn the time into a long number, as shown above.

And then it's going to be a thing to use:

@JsonFormat, its role is to automatically convert date object data into the correct formatted string when the parameter is out.

Effect:

And then through the degrees Niang know, there is an annotation

@DateTimeFormat

This is used to convert the foreground to the background string variable to the date type. The request message only needs to pass in the YYYYMMDDHHMMSS string and is automatically converted to date type data

However, there is also information that @JsonFormat can not only complete the background to the foreground parameter transfer type conversion, but also to achieve the foreground to background type conversion. When Content-type is Application/json, the type conversion is preferred using the pattern of @jsonformat. Instead of using @datetimeformat for type conversions.

The question about the entry is not studied here, there is time to study it later.

About the problem of javadate data returning to the front-end variable numbers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.