class Test
{
public static void main(String[] args) throws Exception
{
Date d = null;
while(true)
{
d = new Date();//没循环一次,重新创建Date实例
long time = d.getTime();
System.out.println(time);
Thread.sleep(2000);
}
}
} 作者: 颜春 时间: 2013-2-28 22:17
Date.getTime();
返回:
自 1970 年 1 月 1 日 00:00:00 GMT 以来此日期表示的毫秒数。
想要得到当前时间
class DateTest
{
public static void main(String[] args) throws Exception
{
while(true)
{
long time = System.currentTimeMillis();//获得系统当前时间
System.out.println(time);
Thread.sleep(2000);