代码如下
package com.data.dp;import org.apache.commons.lang3.StringUtils;import java.text.ParseException;
import java.text.SimpleDateFormat;public class testDate {public static void main(String[] args) throws ParseException {SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");String closeDate = StringUtils.deleteWhitespace("2020-05-22");String startDate = StringUtils.deleteWhitespace("2019-05-22");int days = (int)((df.parse(closeDate).getTime()-df.parse(startDate).getTime())/(24 * 60 * 60 * 1000));System.out.println(days);}}