MySQL inserts a value of the date type

Source: Internet
Author: User

Two Methods for MySQL to insert a date value
1) string is used for receiving from the page, and preparedstatement. setstring () is directly used in Dao ();
2) Same, the string is used for receiving, and then formatted:
Simpledateformat SDF = new simpledateformat ("yyyy-mm-dd ");
Java. util. Date card_indate = NULL;
Card_indate = SDF. parse (indate );
InsertCode:
Preparedstatement. setdate (Num, new java. SQL. Date (card_indate.gettime ()));

 

I hope it will be useful to those who just started using MySQL.

Oracle, which has been used in the past, is still very powerful. There is a to_date function, which can be used directly with to_date ('value', 'yyyy-mm-dd ''').

No system functions need to be optimized for a while.

Haha

Related Article

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.