ImportJava.util.Calendar;Importjava.util.Date; Public classDaojishi {StaticString countdown= ""; Public Static voidMain (string[] args) {//Turn on Countdowntime2 (); System.out.println ("Countdown=" +countdown); } /*** Countdown, set time stamp*/ Private Static voidtime2 () {Calendar C=calendar.getinstance (); C.set (C.get (Calendar.year), (C.get (calendar.month)+ 1), C.get (Calendar.day_of_month) +1, C.get (Calendar.hour_of_day), C.get (Calendar.minute), C.get (Calendar.SECOND));//note the setting of the month, 0-11 means January-December LongEndTime =C.gettimeinmillis (); Date Date=NewDate (); LongStartTime =Date.gettime (); LongMidtime = (endtime-starttime)/1000; while(Midtime > 0) {Midtime--; LongHH = midtime/60/60% 60; LongMM = midtime/60% 60; LongSS = Midtime% 60; System.out.println ("Still left" + hh + "hours" + mm + "Minutes" + SS + "SEC"); System.out.println (HH+ "" +mm+ "" +ss+ ""); Countdown=hh+ "" +mm+ "" +ss+ ""; Try{Thread.Sleep (1000); } Catch(interruptedexception e) {e.printstacktrace (); } } }}
Reference:
Http://www.cnblogs.com/heizai002/p/6862625.html
http://blog.csdn.net/kookob/article/details/6885383
Java 24-hour countdown case