1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
public static long getTimeDifference(String endDate ,String currentDate){ DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date end = df.parse(endDate); Date current = df.parse(currentDate); long diff = end.getTime() - current.getTime(); long days = diff / (1000 * 60 * 60 * 24); return days; } catch (Exception e) { System.out.println("算时间差错误"+e); } return 0; }
|