public static void main(String[] args) {
try {
//日期的差距
String createTime = "2018-01-01 01:02:11";
String newTime = "2018-01-01 23:02:02";
Date newday = dateFormatter.parse(newTime);
Date oldDay = dateFormatter.parse(createTime);
long intervalDay = (newday.getTime() - oldDay.getTime())/(24*60*60*1000);
System.out.println(intervalDay);
} catch (Exception e) {
e.printStackTrace();
}
}
//获取当前时间的前一天时间
long time = System.currentTimeMillis();
Date nowDate = new Date(time);
Date yesterday = new Date(time - 86400000L);