当前时间到1970-01-01 00:00:00 的毫秒数

来源:互联网 发布:剪辑音频的软件 编辑:程序博客网 时间:2024/05/16 17:49

package socket;

 

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

 

public class aa {

       public static void main(String[] args) throws ParseException{ 

              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 

              Date currentTime=new Date(); 

              //将截取到的时间字符串转化为时间格式的字符串 

              Date beginTime=sdf.parse("1970-01-01 00:00:00"); 

              //默认为毫秒 

              long interval=(currentTime.getTime()-beginTime.getTime());

              System.out.println(interval);

       }

}

0 0
原创粉丝点击