//核心思想就是:将Date类型转换成long值,相减,得到差值,再除以一天的毫秒值。
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    Date startTime = dateFormat.parse("2023-11-09 22:37:01.123");
    Date endTime =dateFormat.parse("2023-11-10 22:37:01.123");
    long starTime = startTime.getTime();
    long endTime = endTime.getTime();
    long diff = endTime-starTime;
    long day = diff/24/60/60/1000;//差值除以一天的毫秒数
    System.out.println("相差天数为:"+ day);
    //如果要保留小数
    double d = (double)diff/24/60/60/1000;
11-10 04:02