package com.cavaness.quartzbook.chapter3;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* 测试Date()
* @author Kevin
*
*/
public class DateTest {
private static Log log = LogFactory.getLog(DateTest.class);
/**
* @param args
*/
public static void main(String[] args) {
DateTest dateTest = new DateTest();
dateTest.testDate();
}
public void testDate() {
log.info(new Date()); // 获取当地当前时间
log.info(new Date().getTime()); // 返回自 1970 年 1 月 1 日 00:00:00 GMT 以来距今的毫秒数
long milliseconds = 666666666666l;
log.info(new Date(milliseconds));// 返回自1970 年 1 月 1 日 00:00:00 GMT 过去666666666666l毫秒数后的时间
log.info(new Date(new Date().getTime())); // 效果和 new Date()一样
}
}