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

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 + "天");

    }
}

你可能感兴趣的:(java)