### Question:
DateUtils { public static Date getDateBeforePeriod(String perStr, Date curDate) { Period pr = getPeriod(perStr); DateTime dt = new DateTime(curDate); return dt.minus(pr).toDate(); }  static Period getPeriod( String perStr ); static Date getDateAfterPeriod(String perStr, Date curDate); static Date getDateBeforePeriod(String perStr, Date curDate); static ScheduleExpression getScheduleExpression( String cron ); static ScheduleExpression getHourlyScheduleExpression( Date date ); static ScheduleExpression getDailyScheduleExpression( Date date ); static ScheduleExpression getWeeklyScheduleExpression( Date date ); static ScheduleExpression getMonthlyScheduleExpression( Date date ); static DateTimeFormatter getDateTimeFormatter(); static String dateToStr( Date date);  }### Answer:
@Test public void testGetDateBefore() { DateTime dt = new DateTime(2015, 1, 1, 1, 1); Date expected = dt.minusHours(1).minusMinutes(5).toDate(); Date result = DateUtils.getDateBeforePeriod("1s5d", dt.toDate()); Assert.assertEquals(expected, result); result = DateUtils.getDateBeforePeriod("1h5M", dt.toDate()); Assert.assertEquals(expected, result); }