本文整理汇总了Java中org.joda.time.DateMidnight.withField方法的典型用法代码示例。如果您正苦于以下问题:Java DateMidnight.withField方法的具体用法?Java DateMidnight.withField怎么用?Java DateMidnight.withField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateMidnight
的用法示例。
在下文中一共展示了DateMidnight.withField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentWeek
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public Interval getCurrentWeek() {
final DateMidnight beginningOfSemester = new DateMidnight(getBegginingOfLessonPeriod());
final DateMidnight firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
final int currentWeek = calculateCurrentWeekOffset();
final DateMidnight start = firstMonday.plusWeeks(currentWeek);
return new Interval(start, start.plusWeeks(1));
}
示例2: getResponseWeek
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public Interval getResponseWeek() {
final DateMidnight beginningOfSemester = new DateMidnight(getBegginingOfLessonPeriod());
final DateMidnight firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
final DateMidnight secondMonday = firstMonday.plusWeeks(1);
final DateMidnight endOfSemester = new DateMidnight(getEndOfExamsPeriod());
final DateMidnight lastMonday = endOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
final DateMidnight endOfResponsePeriod = lastMonday.plusWeeks(2);
return (secondMonday.isEqualNow() || secondMonday.isBeforeNow()) && endOfResponsePeriod.isAfterNow() ? getPreviousWeek() : null;
}
示例3: calculateCurrentWeekOffset
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public int calculateCurrentWeekOffset() {
final DateMidnight beginningOfLessonPeriod = new DateMidnight(getBegginingOfLessonPeriod());
final DateMidnight firstMonday = beginningOfLessonPeriod.withField(DateTimeFieldType.dayOfWeek(), 1);
final DateMidnight thisMonday = new DateMidnight().withField(DateTimeFieldType.dayOfWeek(), 1);
final Interval interval = new Interval(firstMonday, thisMonday);
return interval.toPeriod(PeriodType.weeks()).getWeeks();
}
示例4: getThisMonday
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public DateMidnight getThisMonday() {
final DateTime beginningOfSemester = getBeginDateYearMonthDay().toDateTimeAtMidnight();
final DateTime endOfSemester = getEndDateYearMonthDay().toDateTimeAtMidnight();
if (beginningOfSemester.isAfterNow() || endOfSemester.isBeforeNow()) {
return null;
}
final DateMidnight now = new DateMidnight();
return now.withField(DateTimeFieldType.dayOfWeek(), 1);
}