我怎样才能在下周从安卓那里休息一天?
我为周五和周日设定的时间结束了。我希望你下周五去。
这是我的代码;
/**
* Set Friday Alarm
*/
getNotfDay.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
getNotfDay.set(Calendar.HOUR_OF_DAY, myCustomTime.getHours());
getNotfDay.set(Calendar.MINUTE, myCustomTime.getMinutes());
getNotfDay.set(Calendar.SECOND, myCustomTime.getSeconds());
/**
* 30 minute later from alarm time
*/
getNotfDay.add(Calendar.MINUTE, 30);
/**
* If Friday time before currently time is set Sunday
*/
if (getNotfDay.getTime().before(Utils.longToDate(System.currentTimeMillis()))) {
getNotfDay.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
getNotfDay.set(Calendar.HOUR_OF_DAY, myCustomTime2.getHours());
getNotfDay.set(Calendar.MINUTE, myCustomTime2.getMinutes());
}
Utils.java
public static Date longToDate(long timeMillis){
return new Date(timeMillis);
}
答案 0 :(得分:1)
您可以添加7天(1周)。
//Set to this week's Friday
getNotfDay.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
getNotfDay.set(Calendar.HOUR_OF_DAY, myCustomTime.getHours());
getNotfDay.set(Calendar.MINUTE, myCustomTime.getMinutes());
getNotfDay.set(Calendar.SECOND, myCustomTime.getSeconds());
getNotfDay.add(Calendar.DATE, 7);