當前位置: 首頁>>代碼示例>>Java>>正文


Java Calendar.getMinimum方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:aumarbello,項目名稱:Tasks,代碼行數:61,代碼來源:TaskListFragment.java


注:本文中的java.util.Calendar.getMinimum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。