1. You can obtain the system time through the default constructor or instance of Calendar or Date. However, the current Date is mainly processed by the Calendar ar. In addition, we can also obtain the day of the week (starting from Sunday), day [java] public static String getCurrentTime () {Calendar c = Calendar. getInstance (); // HH 24 hour & hh 12 hour, E-week SimpleDateFormat sdf = new SimpleDateFormat ("MM/dd/yyyy e hh: mm: ss "); return sdf. format (c. getTime ();} public static void printTodayInfo () {Date date = new Date (); Calendar c = Calendar ar. getInstance (); c. setTime (date); System. out. println ("Time For today: "+ date. toString (); System. out. println ("Day for today:" + c. get (Calendar. DAY_OF_WEEK); System. out. println ("Time for today:" + c. get (Calendar. DAY_OF_MONTH); System. out. println ("Time for today:" + c. get (Calendar. DAY_OF_YEAR);} 2. obtain the historical time compared to the current time, such as yesterday, last week, last month, and last year. [java] public static String getYesterday () {Calendar c = Calendar. getInstance (); c. add (Calendar. DATE,-1); SimpleDateFormat sdf = new S ImpleDateFormat ("MM/dd/yyyy"); return sdf. format (c. getTime ();} public static String getLastMonth () {Calendar c = Calendar. getInstance (); c. add (Calendar. MONTH,-1); SimpleDateFormat sdf = new SimpleDateFormat ("MM/dd/yyyy"); return sdf. format (c. getTime ();} public static String getLastYear () {Calendar c = Calendar. getInstance (); c. add (Calendar. YEAR,-1); SimpleDateFormat sdf = new SimpleDateForma T ("MM/dd/yyyy"); return sdf. format (c. getTime ();} 3. set a historical time [java] public static void setDate () {Calendar c = Calendar. getInstance (); // note that the month start from 0 c. set (2013, 0, 25, 14, 48, 20); SimpleDateFormat sdf = new SimpleDateFormat ("MM/dd/yyyy HH: mm: ss"); System. out. println (sdf. format (c. getTime (); String birthdate = "01/25/2012 13:11:12"; Date date = new Date (); try {date = sdf. p Arse (birthdate);} catch (ParseException e) {// TODO Auto-generated catch block e. printStackTrace ();} c. setTime (date); System. out. println (sdf. format (c. getTime ();} 4. the comparison between the time and the long type shows that the time corresponding to 0 is 08:00:00, and 1000 will be added for every 1 s increase in the future. In this way, we can get different time. [Java] public static void checkLongAndDate () {Calendar c = Calendar. getInstance (); c. setTimeInMillis (0); SimpleDateFormat sdf = new SimpleDateFormat ("MM/dd/yyyy HH: mm: ss"); // output is 01/01/1970 08:00:00 System. out. println (sdf. format (c. getTime (); c. setTimeInMillis (c. getTimeInMillis () + 1000*60*60*24); System. out. println (sd