//用户输入一个时间,得到当前时间 判断两个时间的时间差(天为单位)
public void Difference(String date) {
Date dt = null;
try {
dt = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss").parse(date);
} catch (ParseException e) {
logger.info(e.getMessage());
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
long timethis = calendar.getTimeInMillis();
calendar.setTime(dt);
long timeend = calendar.getTimeInMillis();
//将时间转化为天 返回一个int型负数
long theday = (timeend - timethis) / (1000 * 60 * 60 * 24);
//将负数转换为正数并输出
System.out.println(0-theday);