ImportJava.text.SimpleDateFormat;Importjava.util.Date;ImportJava.util.Calendar; Public classmainprocess { Public Static voidMain (string[] args) { //func1
Calendar Cld=calendar.getinstance (); intYY =Cld.get (calendar.year); intMM = Cld.get (calendar.month) +1; intDD =Cld.get (calendar.date); intHH =Cld.get (Calendar.hour_of_day); intMM =Cld.get (Calendar.minute); intSS =Cld.get (Calendar.second); intMI =Cld.get (Calendar.millisecond); //from an integral type, so the format does not add 0, such as 2016/5/5-1:1:32:694System.out.println (YY + "/" + mm + "/" + DD + "-" + HH + ":" + mm + ":" + SS + "" + "+MI); //Func2Calendar cal =calendar.getinstance (); Date Date=Cal.gettime (); //2016/05/05-01:01:34:364System.out.println (NewSimpleDateFormat ("Yyyy/mm/dd-hh:mm:ss:sss"). Format (date); //func3 2016/05/05-01:01:34:364System.out.println (NewSimpleDateFormat ("Yyyy/mm/dd-hh:mm:ss:sss"). Format (NewDate ())); }}
Java to get the current system time, accurate to milliseconds of several methods