java-org.springframework.core.convert.conversionfailedexception-front-End pass string parsing date exception

Source: Internet
Author: User
about SPRINGMVC foreground date as entity class object parameter type conversion error Resolution Exception Information:
Field error in object ' Tblhouse ' on field ' Housetime ': Rejected value [2018-01-26]; codes [Typemismatch.tblhouse.housetime,typemismatch.housetime,typemismatch.java.util.date,typemismatch]; arguments [Org.springframework.context.support.DefaultMessageSourceResolvable:codes [Tblhouse.housetime, Housetime]; arguments []; Default message [Housetime]]; Default message [Failed to convert property value of type ' java.lang.String ' to required type ' java.util.Date ' for Propert Y ' housetime '; Nested exception is org.springframework.core.convert.ConversionFailedException:Failed to convert from type [ Java.lang.String] to type [@com. Baomidou.mybatisplus.annotations.TableField @ Org.springframework.format.annotation.DateTimeFormat java.util.Date] for value ' 2018-01-26 '; Nested exception is Java.lang.IllegalArgumentException:Invalid format: "2018-01-26" was too short]
description of the exception scene

The front end of the input box for the selection date of the plug-in, select the date completed, request the background to add data, error. resolution Method

You can resolve this error by adding the annotation to an attribute in the entity class

   @DateTimeFormat (pattern = "YYYY-MM-DD")
    private Date housetime;

Reference articles:

Http://www.linuxidc.com/Linux/2017-06/145204.htm

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.