本文整理匯總了Java中org.joda.time.MutableDateTime.addDays方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableDateTime.addDays方法的具體用法?Java MutableDateTime.addDays怎麽用?Java MutableDateTime.addDays使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.MutableDateTime
的用法示例。
在下文中一共展示了MutableDateTime.addDays方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
@Override
public Set<Integer> parse(DateTime dateTime) {
Set<Integer> set = new HashSet<>();
MutableDateTime mdt = dateTime.dayOfMonth().withMaximumValue().toMutableDateTime();
while (mdt.getDayOfWeek() > 5) {
mdt.addDays(-1);
}
set.add(mdt.getDayOfMonth());
return set;
}
示例2: applyCriteriaDefaults
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
protected DocumentSearchCriteria applyCriteriaDefaults(DocumentSearchCriteria criteria) {
DocumentSearchCriteria.Builder comparisonCriteria = createEmptyComparisonCriteria(criteria);
boolean isCriteriaEmpty = criteria.equals(comparisonCriteria.build());
boolean isTitleOnly = false;
boolean isDocTypeOnly = false;
if (!isCriteriaEmpty) {
comparisonCriteria.setTitle(criteria.getTitle());
isTitleOnly = criteria.equals(comparisonCriteria.build());
}
if (!isCriteriaEmpty && !isTitleOnly) {
comparisonCriteria = createEmptyComparisonCriteria(criteria);
comparisonCriteria.setDocumentTypeName(criteria.getDocumentTypeName());
isDocTypeOnly = criteria.equals(comparisonCriteria.build());
}
if (isCriteriaEmpty || isTitleOnly || isDocTypeOnly) {
DocumentSearchCriteria.Builder criteriaBuilder = DocumentSearchCriteria.Builder.create(criteria);
Integer defaultCreateDateDaysAgoValue = null;
if (isCriteriaEmpty || isDocTypeOnly) {
// if they haven't set any criteria, default the from created date to today minus days from constant variable
defaultCreateDateDaysAgoValue = KewApiConstants.DOCUMENT_SEARCH_NO_CRITERIA_CREATE_DATE_DAYS_AGO;
} else if (isTitleOnly) {
// If the document title is the only field which was entered, we want to set the "from" date to be X
// days ago. This will allow for a more efficient query.
defaultCreateDateDaysAgoValue = KewApiConstants.DOCUMENT_SEARCH_DOC_TITLE_CREATE_DATE_DAYS_AGO;
}
if (defaultCreateDateDaysAgoValue != null) {
// add a default create date
MutableDateTime mutableDateTime = new MutableDateTime();
mutableDateTime.addDays(defaultCreateDateDaysAgoValue.intValue());
criteriaBuilder.setDateCreatedFrom(mutableDateTime.toDateTime());
}
criteria = criteriaBuilder.build();
}
return criteria;
}
示例3: nextTimeAfter
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
@CoverageIgnore
public DateTime nextTimeAfter(DateTime afterTime, DateTime dateTimeBarrier) {
MutableDateTime nextTime = new MutableDateTime(afterTime);
nextTime.setMillisOfSecond(0);
nextTime.secondOfDay().add(1);
while (true) { // day of week
while (true) { // month
while (true) { // day of month
while (true) { // hour
while (true) { // minute
while (true) { // second
if (secondField.matches(nextTime.getSecondOfMinute())) {
break;
}
nextTime.secondOfDay().add(1);
}
if (minuteField.matches(nextTime.getMinuteOfHour())) {
break;
}
nextTime.minuteOfDay().add(1);
nextTime.secondOfMinute().set(0);
}
if (hourField.matches(nextTime.getHourOfDay())) {
break;
}
nextTime.hourOfDay().add(1);
nextTime.minuteOfHour().set(0);
nextTime.secondOfMinute().set(0);
}
if (dayOfMonthField.matches(new LocalDate(nextTime))) {
break;
}
nextTime.addDays(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
if (monthField.matches(nextTime.getMonthOfYear())) {
break;
}
nextTime.addMonths(1);
nextTime.setDayOfMonth(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
if (dayOfWeekField.matches(new LocalDate(nextTime))) {
break;
}
nextTime.addDays(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
return nextTime.toDateTime();
}
示例4: nextTimeAfter
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
public DateTime nextTimeAfter(DateTime afterTime, DateTime dateTimeBarrier) {
MutableDateTime nextTime = new MutableDateTime(afterTime);
nextTime.setMillisOfSecond(0);
nextTime.secondOfDay().add(1);
while (true) { // day of week
while (true) { // month
while (true) { // day of month
while (true) { // hour
while (true) { // minute
while (true) { // second
if (secondField.matches(nextTime.getSecondOfMinute())) {
break;
}
nextTime.secondOfDay().add(1);
}
if (minuteField.matches(nextTime.getMinuteOfHour())) {
break;
}
nextTime.minuteOfDay().add(1);
nextTime.secondOfMinute().set(0);
}
if (hourField.matches(nextTime.getHourOfDay())) {
break;
}
nextTime.hourOfDay().add(1);
nextTime.minuteOfHour().set(0);
nextTime.secondOfMinute().set(0);
}
if (dayOfMonthField.matches(new LocalDate(nextTime))) {
break;
}
nextTime.addDays(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
if (monthField.matches(nextTime.getMonthOfYear())) {
break;
}
nextTime.addMonths(1);
nextTime.setDayOfMonth(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
if (dayOfWeekField.matches(new LocalDate(nextTime))) {
break;
}
nextTime.addDays(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
return nextTime.toDateTime();
}