⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 beijing.java

📁 java编写的日期倒计时计算,可以精确到秒数
💻 JAVA
字号:
import java.util.*;
import java.text.*;
public class BeiJing
{
	public static void main(String[] args)
	{
		Date dates=new Date();
		SimpleDateFormat simple=new SimpleDateFormat("yyyy年MM月dd日HH点mm分ss秒");
		String nowTime=simple.format(dates);
		System.out.println("当前时间是:"+nowTime);
		
		int year=Integer.parseInt(nowTime.substring(0,4));
		int month=Integer.parseInt(nowTime.substring(5,7));
		int date=Integer.parseInt(nowTime.substring(8,10));
		int hour=Integer.parseInt(nowTime.substring(11,13));
		int minu=Integer.parseInt(nowTime.substring(14,16));
		int second=Integer.parseInt(nowTime.substring(17,19));
		
		Calendar cal=Calendar.getInstance();
		cal.set(year,month,date,hour,minu,second);
		long startTime=cal.getTimeInMillis();
		cal.set(2006,1,10,0,0,0);
		long endTime=cal.getTimeInMillis();   //从前一个时间截至到目前所走过的毫秒时间
		long tt=(endTime-startTime)/1000;
		while(tt>0)
		{
			System.out.println("离2006年1月10日0点整有:"+tt+"秒");
			try
			{
				Thread.sleep(1000);
			}
			catch(Exception e){}
			tt--;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -