DateUtil { public static String getEndDate(String startDateString, int noDays, Locale locale) { Date endDate = getEndDate(startDateString, noDays); DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); return df.format(endDate); }  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);  }
@Test public void getEndDate_validDate() { String someDate = "10.05.14"; String deFormattedDate = DateUtil.getEndDate(someDate, 30, Locale.GERMAN); System.out.println("deFormattedDate: " + deFormattedDate); assertTrue(deFormattedDate.equals("09.06.2014")); }
@Test public void getEndDate_invalidDate() { String someDate = "noDate"; String deFormattedDate = DateUtil.getEndDate(someDate, 30, Locale.GERMAN); System.out.println("deFormattedDate: " + deFormattedDate); DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.GERMAN); String today = df.format(new Date()); assertTrue(deFormattedDate.equals(today)); }