1. SimpleDateFormat formatter = new SimpleDateFormat ("MM dd, yyyy HH: mm: ss ");
2. Date curDate = new Date (System. currentTimeMillis (); // obtain the current time
3. String str = formatter. format (curDate );
4. import java. text. simpleDateFormat; SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH: mm: ss"); Date curDate = new Date (System. currentTimeMillis (); // obtain the current time String str = formatter. format (curDate); you can obtain the current year and month, or write separately:
5.
6. Java code
7. SimpleDateFormat sDateFormat = new SimpleDateFormat ("yyyy-MM-dd hh: mm: ss ");
8. String date = sDateFormat. format (new java. util. Date ());
9. simpleDateFormat sDateFormat = new SimpleDateFormat ("yyyy-MM-dd hh: mm: ss"); String date = sDateFormat. format (new java. util. date (); if you want to get the current year and month, you can write this statement (only get the same time or second ):
10.
11. Java code
12. SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM ");
13. String date = sdf. format (new java. util. Date ());
14. simpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM"); String date = sdf. format (new java. util. date (); of course, you can specify the time zone (to be ):
15.
16. df = DateFormat. getDateTimeInstance (DateFormat. FULL, DateFormat. FULL, Locale. CHINA );
17. System. out. println (df. format (new Date ()));
From the wanli_smile Column