作业题: 算算自己活了多少天?

package cn.zmh.Date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateDemo3 {
    public static void main(String[] args) throws ParseException {
        liver3();
    }
    public static void liver() throws ParseException{
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date bir = sdf.parse("1998-03-16");
        long time = bir.getTime();
        System.out.println(time);
        Date d = new Date();
        long time1 = d.getTime();
        System.out.println(time1);
        System.out.println((time1-time)/1000/3600/24);
    }

}

猜你喜欢

转载自www.cnblogs.com/zhangmenghui/p/10562206.html