Settimestamp and MySQL datetime field issues

Source: Internet
Author: User

Requirement: Date data for seconds and minutes when the database is retained

Process: In MySQL, the date data type can only be stored in the date, so only the DateTime type, that in JDBC, call the Settimestamp () method, when the data is fetched, use the result set call Gettimstamp () method.

Issue: Although the Date object timestamp is removed, its ToString () method displays a data format that is YYYY-MM-DD hh:mm:ss.0, which is the millisecond value behind it and cannot be displayed directly on the page.

Workaround: The displayed string is processed on the display page. Use the JSTL tag

<%@ taglib uri= "http://java.sun.com/jsp/jstl/functions" prefix= "FN"%>

${fn:substring (item[' receive_date '],0,19)}

The string item[' receive_date '] is cut, the millisecond value is removed, and the desired string is obtained.

Settimestamp and MySQL datetime field issues

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.