// date为当前时间 date1为过期时间
public static String judgeDeadLine(Date date, Date date1) throws IllegalAccessException {
if (date == null || date1 == null)
throw new IllegalAccessException("日期不可为空");
long time1 = date.getTime(), time2 = date1.getTime();
if (time1 - time2 > 0) {
System.out.println("已经过期");
return null;
}
long second = (time2 - time1) / 1000;
StringBuilder sb = new StringBuilder("还剩");
int day = (int) (second / 86400);
sb.append(day).append("天");
second %= 86400;
int hour = (int) (second / 3600);
sb.append(hour).append("小时");
second %= 3600;
int min = (int) (second / 60);
sb.append(min).append("分").append(second %= 60).append("秒过期");
return sb.toString();
}