JSTL label Fmt:formatdate formatted date String to date

Source: Internet
Author: User

In one of my previous blogs:

wrote about how to convert the background date type to the foreground display, today I'm using the fourth method

<value= "&{diary.releasedate}"  type= "date"  pattern  = "Yyyy-mm-dd"/>

Appears: Unable to convert string "&{diary.releasedate}" to class ' java.util.Date ' for attribute ' value ': Property Editor N OT registered with the Propertyeditormanager exception

The reason is that although releasedate is set to the date type in entity diary, &{diary.releasedate} is taken out as a string type and cannot be converted to a date type

The output will be normal as follows

<value= "<%=new Date ()%>"  pattern= "YYYY-MM-DD"/ >

The workaround is to first parse the string to date and then format the date

<value= "${entity.ctime}"  var= "date"  pattern= " Yyyymmddhhmm "/><value=" ${date} "  pattern  = "Yyyy-mm-dd hh:mm"/>

JSTL label Fmt:formatdate formatted date String to date

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.