package com.hp.demo05;
import java.util.Date;
public class Demo02 {
public static void main(String[] args) throws Exception{
int s = 60;
//60秒后的时间
Date mb = new Date();
mb.setMinutes(mb.getMinutes()+1);//原有分钟+1900
long a = mb.getTime();
while (true) {
Date now = new Date();//当前时间
long b = now.getTime();//
long c = a-b;
if (c==0){
System.out.println("时间到了,开始关机...");
Runtime runtime = Runtime.getRuntime();
runtime.exec("shutdown -s -t 60 -f");
break;
}
System.out.println("剩余"+c/1000+"秒关机");
Thread.sleep(1000);
}
}
}
暑期编程PK赛
得CSDN机械键盘等精美礼品!