In Java, date () is no type one said, we call the time format, time type refers to the format after conversion to a string, does not mean the format of Date ();
public void testdate () { //defines the time, and its format defaults to:tue jun 09 11:11:30 gmt+08:00 2015 This style Date date = new date (); //output: Tue Jun 09 11:11:30 GMT+08:00 2015 SYSTEM.OUT.PRINTLN (date); //define time conversion format dateformat dfm =new simpledateformat ("Yyyy-mm-dd hh:mm:ss"); //converts a time into a string of the specified format string time= Dfm.format (date); //string after output transition format: 2015-06-09 11:35:52 system.out.println (Time); try { /* will be formatted as "YYYY-MM-DD HH:MM:SS" * date display is still tue when converted to time jun 09 11:11:30 gmt+08:00 2015 This style */ date dm=dfm.parse ( Time.tostring ()); // Verify that the output is:tue jun 09 11:35:52 gmt+08:00 2015 system.out.println (DM); //converted to string output as: tue jun 09 11:35:52 gmt+ 08:00 2015 System.out.println (dm.tostrING ()); } catch (parseexception e) { e.printstacktrace (); } } background output is: tue jun 09 11:11:30 GMT+08:00 2015 2015-06-09 11:36:48 Tue Jun 09 11:36:48 GMT+08:00 2015 tue jun 09 11:36:48 gmt+08:00 2015
This article is from the "9891958" blog, please be sure to keep this source http://9901958.blog.51cto.com/9891958/1659992
Doubts about the Java time format