当前位置: 首页>>代码示例>>Java>>正文


Java DateTime.plusDays方法代码示例

本文整理汇总了Java中hirondelle.date4j.DateTime.plusDays方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.plusDays方法的具体用法?Java DateTime.plusDays怎么用?Java DateTime.plusDays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hirondelle.date4j.DateTime的用法示例。


在下文中一共展示了DateTime.plusDays方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDaysOfWeek

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
protected ArrayList<String> getDaysOfWeek() {
    ArrayList<String> list = new ArrayList<String>();

    SimpleDateFormat fmt = new SimpleDateFormat("EEE", Locale.getDefault());

    // 17 Feb 2013 is Sunday
    DateTime sunday = new DateTime(2013, 2, 17, 0, 0, 0, 0);
    DateTime nextDay = sunday.plusDays(startDayOfWeek - SUNDAY);

    for (int i = 0; i < 7; i++) {
        Date date = CalendarHelper.convertDateTimeToDate(nextDay);
        list.add(fmt.format(date).toUpperCase());
        nextDay = nextDay.plusDays(1);
    }

    return list;
}
 
开发者ID:maheswaranapk,项目名称:Andorid-Material-Drop-Down-Date-Picker,代码行数:18,代码来源:CalendarFragment.java

示例2: insertDefaultWorkTimes

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
public void insertDefaultWorkTimes(DateTime from, DateTime to, Integer taskId, String text) {
	DateTime running = from.getStartOfDay();
	DateTime target = to.getStartOfDay();
	while (running.lteq(target)) {
		// clock-in at start of day (00:00)

		WeekDayEnum weekDay = WeekDayEnum.getByValue(running.getWeekDay());
		int workDuration = getNormalWorkDurationFor(weekDay);
		if (workDuration > 0) {
			createEvent(running, taskId, TypeEnum.CLOCK_IN, text);
			DateTime clockOutTime = running.plus(0, 0, 0, 0, workDuration, 0, 0, DayOverflow.Spillover);
			if (isAutoPauseApplicable(clockOutTime)) {
				int pauseDuration = getAutoPauseDuration(clockOutTime);
				clockOutTime = clockOutTime.plus(0, 0, 0, 0, pauseDuration, 0, 0, DayOverflow.Spillover);
			}
			createEvent(clockOutTime, null, TypeEnum.CLOCK_OUT, null);
		}

		running = running.plusDays(1);
	}
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:22,代码来源:TimerManager.java

示例3: getDaysOfWeek

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
/**
 * To display the week day title
 * 
 * @return "SUN, MON, TUE, WED, THU, FRI, SAT"
 */
private ArrayList<String> getDaysOfWeek() {
	ArrayList<String> list = new ArrayList<String>();

	SimpleDateFormat fmt = new SimpleDateFormat("EEE", Locale.getDefault());

	// 17 Feb 2013 is Sunday
	DateTime sunday = new DateTime(2013, 2, 17, 0, 0, 0, 0);
	DateTime nextDay = sunday.plusDays(startDayOfWeek - SUNDAY);

	for (int i = 0; i < 7; i++) {
		Date date = CalendarHelper.convertDateTimeToDate(nextDay);
		list.add(fmt.format(date).toUpperCase());
		nextDay = nextDay.plusDays(1);
	}

	return list;
}
 
开发者ID:FrancescoDesogus,项目名称:IUM_Project_SwimDroid,代码行数:23,代码来源:CaldroidFragment.java

示例4: setSelectedDates

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
/**
 * Select the dates from fromDate to toDate. By default the background color
 * is holo_blue_light, and the text color is black. You can customize the
 * background by changing CaldroidFragment.selectedBackgroundDrawable, and
 * change the text color CaldroidFragment.selectedTextColor before call this
 * method. This method does not refresh view, need to call refreshView()
 * 
 * @param fromDate
 * @param toDate
 */
public void setSelectedDates(Date fromDate, Date toDate) {
	// Ensure fromDate is before toDate
	if (fromDate == null || toDate == null || fromDate.after(toDate)) {
		return;
	}

	selectedDates.clear();

	DateTime fromDateTime = CalendarHelper.convertDateToDateTime(fromDate);
	DateTime toDateTime = CalendarHelper.convertDateToDateTime(toDate);

	DateTime dateTime = fromDateTime;
	while (dateTime.lt(toDateTime)) {
		selectedDates.add(dateTime);
		dateTime = dateTime.plusDays(1);
	}
	selectedDates.add(toDateTime);
}
 
开发者ID:iSCAU,项目名称:iSCAU-Android,代码行数:29,代码来源:CaldroidFragment.java

示例5: getBeginOfFirstWeekFor

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
/**
 * Get the week start date of the first week of the given year, according to ISO 8601.
 */
public static DateTime getBeginOfFirstWeekFor(int year) {
	DateTime date = new DateTime(String.valueOf(year) + "-01-01 00:00:00");
	while (date.getWeekDay() != WeekDayEnum.THURSDAY.getValue()) {
		date = date.plusDays(1);
	}
	date.minusDays(3);
	return date;
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:12,代码来源:DateTimeUtil.java

示例6: refreshView

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
protected void refreshView() {
	clockOutButton.setEnabled(timerManager.isTracking());
	Task taskToSelect = null;
	if (timerManager.isTracking()) {
		clockInButton.setText(R.string.clockInChange);
		taskToSelect = timerManager.getCurrentTask();
	} else {
		clockInButton.setText(R.string.clockIn);
		taskToSelect = dao.getDefaultTask();
	}
	if (taskToSelect != null) {
		int i = 0;
		for (Task oneTask : tasks) {
			if (oneTask.getId().equals(taskToSelect.getId())) {
				task.setSelection(i);
				break;
			}
			i++;
		}
	}

	if (currentlyShownWeek != null) {
		DateTime monday = DateTimeUtil.stringToDateTime(currentlyShownWeek.getStart());
		DateTime tuesday = monday.plusDays(1);
		DateTime wednesday = tuesday.plusDays(1);
		DateTime thursday = wednesday.plusDays(1);
		DateTime friday = thursday.plusDays(1);
		DateTime saturday = friday.plusDays(1);
		DateTime sunday = saturday.plusDays(1);
		// set dates
		showActualDates(monday, tuesday, wednesday, thursday, friday, saturday, sunday);
		// highlight current day (if it is visible)
		// and reset the highlighting for the other days
		refreshRowHighlighting(monday, tuesday, wednesday, thursday, friday, saturday, sunday);
		// display times
		showTimes(monday, tuesday, wednesday, thursday, friday, saturday, sunday);
	}
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:39,代码来源:WorkTimeTrackerActivity.java

示例7: getDaysOfWeek

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
/**
 * To display the week day title
 * 
 * @return "SUN, MON, TUE, WED, THU, FRI, SAT"
 */
private ArrayList<String> getDaysOfWeek() {
	ArrayList<String> list = new ArrayList<String>();

	// 17 Feb 2013 is Sunday
	DateTime sunday = new DateTime(2013, 2, 17, 0, 0, 0, 0);
	DateTime nextDay = sunday.plusDays(startDayOfWeek - SUNDAY);

	for (int i = 0; i < 7; i++) {
		list.add(nextDay.format("WWW", Locale.ENGLISH).toUpperCase());
		nextDay = nextDay.plusDays(1);
	}

	return list;
}
 
开发者ID:iSCAU,项目名称:iSCAU-Android,代码行数:20,代码来源:CaldroidFragment.java

示例8: getMinutesRemaining

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
/**
 * Get the remaining time for today (in minutes). Takes into account the target work time for the week and also if
 * this
 * is the last day in the working week.
 * 
 * @param includeFlexiTime
 *            use flexi overtime to reduce the working time - ONLY ON LAST WORKING DAY OF THE WEEK!
 * @return {@code null} either if today is not a work day (as defined in the options) or if the regular working time
 *         for today is already over
 */
public Integer getMinutesRemaining(boolean includeFlexiTime) {
	DateTime dateTime = DateTimeUtil.getCurrentDateTime();
	WeekDayEnum weekDay = WeekDayEnum.getByValue(dateTime.getWeekDay());
	if (isWorkDay(weekDay)) {
		TimeSum alreadyWorked = null;
		TimeSum target = null;
		boolean onEveryWorkingDayOfTheWeek = preferences.getBoolean(Key.FLEXI_TIME_TO_ZERO_ON_EVERY_DAY.getName(),
			false);
		if (!isFollowedByWorkDay(weekDay) || onEveryWorkingDayOfTheWeek) {
			alreadyWorked = calculateTimeSum(dateTime, PeriodEnum.WEEK);
			if (includeFlexiTime) {
				// add flexi balance from week start
				TimeSum flexiBalance = getFlexiBalanceAtWeekStart(DateTimeUtil.getWeekStart(dateTime));
				alreadyWorked.addOrSubstract(flexiBalance);
			}

			final String targetValueString = preferences.getString(Key.FLEXI_TIME_TARGET.getName(), "0:00");
			final TimeSum targetTimePerWeek = parseHoursMinutesString(targetValueString);
			final TimeSum targetTimePerDay = new TimeSum();
			targetTimePerDay.add(0, targetTimePerWeek.getAsMinutes() / countWorkDays());
			DateTime weekStart = DateTimeUtil.getWeekStart(dateTime);
			target = new TimeSum();
			target.addOrSubstract(targetTimePerDay); // add today as well
			while (weekStart.getWeekDay() != dateTime.getWeekDay()) {
				target.addOrSubstract(targetTimePerDay);
				weekStart = weekStart.plusDays(1);
			}
		} else {
			// not the last work day of the week, only calculate the rest of the daily working time
			alreadyWorked = calculateTimeSum(dateTime, PeriodEnum.DAY);
			int targetMinutes = getNormalWorkDurationFor(weekDay);
			target = new TimeSum();
			target.add(0, targetMinutes);
		}

		Logger.debug("alreadyWorked={0}", alreadyWorked.toString());
		Logger.debug("target={0}", target.toString());

		Logger.debug("isAutoPauseEnabled={0}", isAutoPauseEnabled());
		Logger.debug("isAutoPauseTheoreticallyApplicable={0}", isAutoPauseTheoreticallyApplicable(dateTime));
		Logger.debug("isAutoPauseApplicable={0}", isAutoPauseApplicable(dateTime));
		if (isAutoPauseEnabled() && isAutoPauseTheoreticallyApplicable(dateTime)
			&& !isAutoPauseApplicable(dateTime)) {
			// auto-pause is necessary, but was NOT already taken into account by calculateTimeSum():
			Logger.debug("auto-pause is necessary, but was NOT already taken into account by calculateTimeSum()");
			DateTime autoPauseBegin = getAutoPauseBegin(dateTime);
			DateTime autoPauseEnd = getAutoPauseEnd(dateTime);
			alreadyWorked.substract(autoPauseEnd.getHour(), autoPauseEnd.getMinute());
			alreadyWorked.add(autoPauseBegin.getHour(), autoPauseBegin.getMinute());
		}
		int minutesRemaining = target.getAsMinutes() - alreadyWorked.getAsMinutes();
		Logger.debug("minutesRemaining={0}", minutesRemaining);

		return minutesRemaining;
	} else {
		return null;
	}
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:69,代码来源:TimerManager.java

示例9: doInBackground

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
@Override
protected Boolean doInBackground(GenerateDataTaskParams... params) {
    if (params != null && params.length > 0) {
        taskParams = params[0];
    }

    deleteAllExistingData();

    final List<Food> allFoods = Food.getAllFoods();

    final int numDays = taskParams.getHistoryToGenerate();

    final DateTime today = DateTime.today(TimeZone.getDefault());
    DateTime current = today.minusDays(numDays);

    int i = 0;

    while (current.lteq(today)) {
        createServingsForDay(allFoods, current);

        publishProgress(++i, numDays);

        current = current.plusDays(1);
    }

    return null;
}
 
开发者ID:nutritionfactsorg,项目名称:daily-dozen-android,代码行数:28,代码来源:GenerateDataTask.java

示例10: isDateInWeek

import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
/**
 * Check if a date is in a specific week.
 * 
 * @param date
 *            the date to check
 * @param week
 *            the referenced week
 * @return {@code true} if the date is inside the week, {@code false} otherwise
 */
public static boolean isDateInWeek(DateTime date, Week week) {
	DateTime weekStart = DateTimeUtil.stringToDateTime(week.getStart());
	DateTime weekEnd = weekStart.plusDays(7);
	return weekStart.lteq(date) && weekEnd.gt(date);
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:15,代码来源:WeekUtil.java


注:本文中的hirondelle.date4j.DateTime.plusDays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。