当前日期毫秒数方法

new Date().getTime() 和 System.currentTimeMillis() 是一样的

public class TestDate {
   
    public static void main(String[] args) {
        Date now= new Date();
  
        //当前日期的毫秒数
        System.out.println("Date.getTime() \t\t\t返回值: "+now.getTime());
        //通过System.currentTimeMillis()获取当前日期的毫秒数
        System.out.println("System.currentTimeMillis() \t返回值: "+System.currentTimeMillis());
           
    }
}
posted @ 2020-11-28 22:13  yikolemon  阅读(61)  评论(0)    收藏  举报