Java format time string to date date turn string

Source: Internet
Author: User
Tags java format

---restore content starts---

The date type is converted to string:

Date date = new Date ();
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd");
String Dbegin = Sdf.format (date);

The string type is converted to date:

String start= "2017-11-10";

SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd");
Date Dbegin = Sdf.parse (start);

Used to be date, string, and then do the processing, today found an interesting phenomenon ...

And then I found out. The parse method turns the time wrong when it transforms the date ... Wrong 、、、、、 wrong 、、、、

Even more outrageous is .... Change the time format and then there's no problem .... This feeling,,,, acid cool AH!!!

Java format time string to date date turn string

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.