@Test public void getRemainingDays_invalidDate() { String someDate = "noDate"; int days = DateUtil.getRemainingDays(someDate, 3); System.out.println("getRemainingDays: " + days); assertTrue(days == 0); }
public static int getRemainingDays(String startDateString, int noDays) { Date endDate = getEndDate(startDateString, noDays); Calendar cal = Calendar.getInstance(); cal.setTime(endDate); long remainingMills = cal.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); long days = remainingMills / (24 * 60 * 60 * 1000); return Math.round(days); }
DateUtil { public static int getRemainingDays(String startDateString, int noDays) { Date endDate = getEndDate(startDateString, noDays); Calendar cal = Calendar.getInstance(); cal.setTime(endDate); long remainingMills = cal.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); long days = remainingMills / (24 * 60 * 60 * 1000); return Math.round(days); } }
DateUtil { public static int getRemainingDays(String startDateString, int noDays) { Date endDate = getEndDate(startDateString, noDays); Calendar cal = Calendar.getInstance(); cal.setTime(endDate); long remainingMills = cal.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); long days = remainingMills / (24 * 60 * 60 * 1000); return Math.round(days); }  }
DateUtil { public static int getRemainingDays(String startDateString, int noDays) { Date endDate = getEndDate(startDateString, noDays); Calendar cal = Calendar.getInstance(); cal.setTime(endDate); long remainingMills = cal.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); long days = remainingMills / (24 * 60 * 60 * 1000); return Math.round(days); }  static boolean isMoreThanOneDayBefore(Date date); static Date getYesterday(); static Date getDayBefore(Date date); static Date getDayBefore(Date date, int numberOfDays); static String extractDate(Date date, Locale locale); static String extractTime(Date date, Locale locale); static DateFilter getDateFilterFromDDaysBeforeToToday(int days); static String getEndDate(String startDateString, int noDays, Locale locale); static int getRemainingDays(String startDateString, int noDays); }
DateUtil { public static int getRemainingDays(String startDateString, int noDays) { Date endDate = getEndDate(startDateString, noDays); Calendar cal = Calendar.getInstance(); cal.setTime(endDate); long remainingMills = cal.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); long days = remainingMills / (24 * 60 * 60 * 1000); return Math.round(days); }  static boolean isMoreThanOneDayBefore(Date date); static Date getYesterday(); static Date getDayBefore(Date date); static Date getDayBefore(Date date, int numberOfDays); static String extractDate(Date date, Locale locale); static String extractTime(Date date, Locale locale); static DateFilter getDateFilterFromDDaysBeforeToToday(int days); static String getEndDate(String startDateString, int noDays, Locale locale); static int getRemainingDays(String startDateString, int noDays);  }