abstract class ProducerConsumer extends Thread {
private static final long DEFAULT_SLEEP_ON_ERROR = 5 * 60 * 1000;
protected static DateTime getNextDate(String weekDayName, String hour) {
DateTime date = new DateTime(new Date().formatDate() + " " + hour);
int weekDay = Week.getWeekDay(weekDayName);
if (weekDay == -1) throw new IllegalArgumentException("invalid week day name: " + weekDayName);
int diff = weekDay - date.getWeekDay();
date = date.addDays(diff < 0 ? diff + 7 : diff);
return date;