java.util.Date class , default format: Thu 21:32:59 CST 2016, the "Day of the week date time China standard Time year" format is not very friendly.
Java.text.SimpleDateFormate class : The class that formats the time, using the following:
----------------------------------output time by format
Date D=new date ();
SimpleDateFormat sdf=new SimpleDateFormat ("Yyyy-mm-dd hh:mm:ss");
System.out.println (Sdf.format (d));
----------------------------------Convert string time to date class
String s1= "2016-02-25 09:39:02";
D=sdf.parse (S1);
System.out.println (d);
------------------------------------date is heavily criticized, the Calendar class is recommended instead of date
The most important role of the date class is to get the current time, while the class also has set time and some other functions, but because of its own design problems, these methods have been criticized many, not recommended, it is recommended to use the Calendar class for time and date processing.
The Java.util.Calendar class is an abstract class that can get a Calendar object by calling the getinstance () static method, which is initialized by the current datetime, which means the current time by default, such as Calendar C = Calendar.getinstance (); then get the datetime information by calling the Get () method, the parameter is the value of the field that needs to be obtained, calendar.year, and so on as the static constant defined in the Calendar class.
The Calendar class provides the GetTime () method to get the Date object, complete the calendar and date conversions, and the Gettimeinmillis () method to get the time value of this calendar, in milliseconds
Date Time Processing class