/**
* 计算两个日期之间相差的天数
*/
@Test
public void testBetweenDays2(){
// 日期字符串
String dateStr1 = “2018-12-27 17:07:07”;
String dateStr2 = “2018-12-31 00:00:00”;
// 获取日期
Date date1 = MyDateUtil.parseDate(dateStr1, "yyyy-MM-dd HH:mm:ss");
Date date2 = MyDateUtil.parseDate(dateStr2, "yyyy-MM-dd HH:mm:ss");
long betweenDays = (date2.getTime() - date1.getTime()) / (1000L*3600L*24L);
System.out.println(betweenDays);
}