本文整理汇总了Java中java.util.Calendar.getMinimum方法的典型用法代码示例。如果您正苦于以下问题:Java Calendar.getMinimum方法的具体用法?Java Calendar.getMinimum怎么用?Java Calendar.getMinimum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Calendar
的用法示例。
在下文中一共展示了Calendar.getMinimum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRepeatTask
import java.util.Calendar; //导入方法依赖的package包/类
private void addRepeatTask(Task task){
task.setAlreadyRepeating(true);
Calendar repeatCalender = Calendar.getInstance();
repeatCalender.setTimeInMillis(dateDialog.getDatePicker().getMaxDate());
Calendar taskCalender = task.getTaskDate();
int currentYear = taskCalender.get(Calendar.YEAR);
int maxYear = repeatCalender.get(Calendar.YEAR);
switch (task.getRepeatCategory()){
case 1:
int currentWeek = taskCalender.get(Calendar.WEEK_OF_YEAR);
int maxWeek = repeatCalender.getMaximum(Calendar.WEEK_OF_YEAR);
Log.d(TAG, "Adding weekly repeat task");
while (currentYear < maxYear){
if (currentYear > todayCalender.get(Calendar.YEAR)){
currentWeek = repeatCalender.getMinimum(Calendar.WEEK_OF_YEAR)- 1;
}
taskCalender.set(Calendar.YEAR, currentYear);
while (currentWeek < maxWeek){
taskCalender.set(Calendar.WEEK_OF_YEAR, ++currentWeek);
task.setTaskDate(taskCalender);
presenter.addTask(task, true);
Log.d(TAG, "Adding for week - " + currentWeek);
}
currentYear++;
Log.d(TAG, "Adding for year - " + currentYear);
}
break;
case 2:
int currentMonth = taskCalender.get(Calendar.MONTH);
int maxMonth = repeatCalender.getMaximum(Calendar.MONTH);
Log.d(TAG, "Adding monthly repeat task");
while (currentYear < maxYear){
if (currentYear > todayCalender.get(Calendar.YEAR)){
currentMonth = repeatCalender.getMinimum(Calendar.MONTH) - 1;
}
taskCalender.set(Calendar.YEAR, currentYear);
while (currentMonth < maxMonth){
taskCalender.set(Calendar.MONTH,
++currentMonth);
task.setTaskDate(taskCalender);
presenter.addTask(task, true);
}
currentYear++;
}
break;
case 3:
while (currentYear < maxYear){
Log.d(TAG, "Adding yearly repeat task");
taskCalender.set(Calendar.YEAR,
++currentYear);
task.setTaskDate(taskCalender);
presenter.addTask(task, true);
}
break;
}
}