/**
* 创建本年度周六、周日
* @param
* @return
*/
public void insertRestDay() {
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00")); //获取东八区时间
int year = c.get(Calendar.YEAR); //获取年
Calendar calendar = new GregorianCalendar(year, 0, 1);
int i = 1;
while (calendar.get(Calendar.YEAR) < year + 1) {
calendar.set(Calendar.WEEK_OF_YEAR, i++);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
if (calendar.get(Calendar.YEAR) == year) {
RestDayModel model = new RestDayModel();
model.put("FDate", calendar.getTime());
model.put("FDescription", "星期天");
RestDayHome.getDao().insert(model);
}
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
if (calendar.get(Calendar.YEAR) == year) {
RestDayModel model = new RestDayModel();
model.put("FDate", calendar.getTime());
model.put("FDescription", "星期六");
RestDayHome.getDao().insert(model);
}
}
}