SPRINGMVC the input string date parameter conversion in the foreground

Source: Internet
Author: User
Tags dateformat

Project, the object property date is of type date, and the foreground incoming date is a string type and is used to the SPRINGMVC frame for conversion.

Note that with the SPRINGMVC framework, the foreground passes in the time parameter and the Initbinder method is implemented to convert the time string to a Date object. The method is implemented and the encapsulate Date Type Property object is automatically completed.

@InitBinder
public void Initbinder (Webdatabinder binder) {
SimpleDateFormat DateFormat = new SimpleDateFormat ("Yyyy-mm-dd hh:mm");
Dateformat.setlenient (FALSE);
Binder.registercustomeditor (Date.class, New Customdateeditor (DateFormat, true)); True: Allow null value to be entered, false: cannot be null
}

SPRINGMVC the input string date parameter conversion in the foreground

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.