本文整理汇总了Java中hirondelle.date4j.DateTime.plus方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.plus方法的具体用法?Java DateTime.plus怎么用?Java DateTime.plus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hirondelle.date4j.DateTime
的用法示例。
在下文中一共展示了DateTime.plus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: createEvent
import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
/**
* Create a new event at current time + the given minute amount.
*
* @param minutesToPredate
* how many minutes to add to "now"
* @param taskId
* the task id (may be {@code null})
* @param type
* the type
* @param text
* the text (may be {@code null})
*/
public void createEvent(int minutesToPredate, Integer taskId, TypeEnum type, String text) {
if (minutesToPredate < 0) {
throw new IllegalArgumentException("no negative minute amount allowed");
}
DateTime targetTime = DateTimeUtil.getCurrentDateTime();
targetTime = targetTime.plus(0, 0, 0, 0, minutesToPredate, 0, 0, DayOverflow.Spillover);
createEvent(targetTime, taskId, type, text);
}