Package Com.sysc.simple;import Java.text.parseexception;import Java.text.simpledateformat;import Java.util.calendar;import Java.util.date;public class Dateutils {public static void show () throws ParseException {// Get current date Calendar now = Calendar.getinstance (); int year = Now.get (calendar.year), int month = Now.get (calendar.month) + 1;//Note Month int day = Now.get (calendar.day_of_month); int hour = Now.get (calendar.hour_of_day); int minute = Now.get (calendar.minute); int second = Now.get (Calendar.second); Long Millis = Now.gettimeinmillis (); System.out.println (Now.gettime ()); SYSTEM.OUT.PRINTLN (year + month + day + hour + minute + second + Millis); Date formatted Print Date d = new Date (); SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); String datenowstr = Sdf.format (d); SYSTEM.OUT.PRINTLN ("Formatted date:" + datenowstr); String parsing to date string str = "2014-9-1 13:08:28"; Date today = Sdf.parse (str); SysTem.out.println ("string turns into Date:" + today); }}
Java gets the current time month date, time formatted print, string to date