本文整理汇总了Java中hirondelle.date4j.DateTime.getWeekDay方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.getWeekDay方法的具体用法?Java DateTime.getWeekDay怎么用?Java DateTime.getWeekDay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hirondelle.date4j.DateTime
的用法示例。
在下文中一共展示了DateTime.getWeekDay方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWeekStart
import hirondelle.date4j.DateTime; //导入方法依赖的package包/类
/**
* Gets the week's start related to the specified date and time.
*
* @param dateTime
* the date and time
* @return a DateTime representing the week start
*/
public static DateTime getWeekStart(DateTime dateTime) {
// go back to this day's start
DateTime ret = dateTime.getStartOfDay();
// go back to last Monday
while (ret.getWeekDay() != WeekDayEnum.MONDAY.getValue()) {
ret = ret.minusDays(1);
}
return ret;
}
示例2: 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;
}
示例3: 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;
}
}