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