Conversion of a double type to a string type in Java

Source: Internet
Author: User
Conversions between string types and double types in Java

When we register the website, often need to fill in personal information, such as name, age, date of birth, etc., the value of the date of birth on the page is passed to the background is a string, and we do need a date type in the database, in turn, when displayed on the page, need to get the date of birth from the database, At this point the type is a date type, and then you need to convert the date type to a string to display on the page, and the Java API gives us the class Dateforamt that the date and string are transported to each other. Dateforamt is an abstract class, so it is usually used by its subclass SimpleDateFormat. SimpleDateFormat has 4 constructors, the most commonly used is the second one.

The pattern in the constructor is the time pattern, what is the mode, the API is described in the following

Get current system time and convert to date type (three steps)

       Set the date format SimpleDateFormat df = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");        New Date () to get the current system time string Time=df.format (new Date ());//Turn to date type Date Consumetime = Df.parse (time);

  

Conversion of a double type to a string type in Java

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.