计算出你来到这个世界多少天

来源:互联网 发布:php单引号转义函数 编辑:程序博客网 时间:2024/05/16 12:29
public class Test{    public void static main(String[]args){         Scanner sc = new Scanner(System.in);         String line = sc.nextLine();        SimpleDateFormat sdf = new SimpleDateFormat("yy/MM/dd HH:mm:ss");        Date d = sdf.parse(line);        long myTime =  d.getTime();        //获取当前毫秒值        long nowtime = System.currentTimeMillis();        long target = nowtime - myTime;        long day = target / 1000 / 60 / 60 / 24;        System.out.println("我来这个世界有" + day + "天");    }}
0 0