当前位置: 首页>>代码示例>>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;未经允许,请勿转载。