public boolean inSert(DailyJoke mDailyJoke) { try { if (getByDate(mDailyJoke.getDate()) != null) { return false; } mDailyJoke.setDate(filterDateFormat(mDailyJoke.getDate())); return mDailyJokeDAO.insert(mDailyJoke) == 1 ? true : false; } catch (Exception e) { e.toString(); } return false; }
/** * 添加段子 * * @param content * @param afterToday true今天之后,反之今天之前 * @return */ public boolean inSertContent(String content, boolean afterToday) { Date date = afterToday ? mDailyJokeDAO.getLastDate() : mDailyJokeDAO.getBeforeDate(); if (date == null) { date = filterDateFormat(new Date()); if (getByDate(date) != null) return false; } else { date = offsetDate(afterToday ? 1 : -1, date); } DailyJoke dj = new DailyJoke(); dj.setContent(content); dj.setDate(date); return inSert(dj); }