1.测试Date()

来源:互联网 发布:post方式传递json数据 编辑:程序博客网 时间:2024/05/16 23:40
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()一样}}

原创粉丝点击