import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class ManyDays {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat ss = new SimpleDateFormat("yyyy-MM-dd");//定义新的时间格式,方便后面解析
        Date date = new Date();//date数据
        String format = ss.format(date);//用format将现在的日期转换为string
        Date begin = ss.parse("2022-02-20");//simpledateformat中的parse方法解析string,需要此前定义格式
        Date end = ss.parse(format);//simpledateformat中的parse方法解析string,需要此前定义格式
        Long endTime = end.getTime();//date中gettime方法,可以返回毫秒数(从1970年开始到时间点)
        Long beginTime = begin.getTime();//date中gettime方法,可以返回毫秒数(从1970年开始到时间点)
        Long mathTime = endTime - beginTime;
        System.out.println("共计过去:" + mathTime / 1000 / 60 / 60 / 24 + "天.");
    }
}