package hhh.daojishi;
import java.util.Date;
public class Djsguoqing {
public static void main(String[] args) throws InterruptedException {
while (true){
Date date1 = new Date(2022-1900, 9, 1, 0, 0, 0);
long gpTime = date1.getTime();
Date atPresent = new Date();
long atTime = atPresent.getTime();
long djs = gpTime-atTime;
getDuration(djs);
Thread.sleep(1000);
}
}
public static String getDuration(long djs){
int ss = 1000;
int mi = ss * 60;
int hh = mi * 60;
int dd = hh * 24;
long day = djs / dd;
long hour = (djs - day * dd) / hh;
long minute = (djs - day * dd - hour * hh)/ mi;
long sec = (djs - day * dd -hour * hh - minute * mi) / ss;
while (true){
if (day > 0) {
System.out.println(day + "天" + hour + "小时" + minute + "分钟"+ sec);
return day + "天" + hour + "小时" + minute + "分钟";
} else if (hour > 0) {
System.out.println(hour + "小时" + minute + "分钟"+ sec);
return hour + "小时" + minute + "分钟";
} else if (minute > 0) {
System.out.println( minute + "分钟"+ sec);
return minute + "分钟";
} else {
System.out.println(sec+"秒");
return 0 + "分钟";
}
}
}
}
国庆节倒计时
最新推荐文章于 2024-08-15 14:47:41 发布