//期望格式模板
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
//到期时间
Date expireTime1= record.getExpireTime();
//当前时间
Date nowdate1=new Date();
//Date转为string类型
String expireTime = DateUtils.format(expireTime1, "yyyy-MM-dd");
String nowdate = DateUtils.format(nowdate1, "yyyy-MM-dd");
//并且格式化
Date fexpireTime = sdf.parse(expireTime);
Date fnowdate= sdf.parse(nowdate);
//减出天数
long stateTimeLong = fnowdate.getTime();
long endTimeLong = fexpireTime.getTime();
//结束时间扣除现在时间
long day = (endTimeLong-stateTimeLong)/(24*60*60*1000);
record.setCount(day);
网友评论