當前位置: 首頁>>代碼示例>>Java>>正文


Java DateUtils.addDays方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.time.DateUtils.addDays方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.addDays方法的具體用法?Java DateUtils.addDays怎麽用?Java DateUtils.addDays使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.time.DateUtils的用法示例。


在下文中一共展示了DateUtils.addDays方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@BeforeClass
public void setUp() throws Exception {
  aggregatedStatusDAO = MongoConnector.getInstance().getAggregatedStatusDAO();
  monthDetailDAO = MongoConnector.getInstance().getMonthDetailDAO();

  String baseEnvName = this.getClass().getName();
  environemntNames = new String[]{baseEnvName + UUID.randomUUID(), baseEnvName + UUID.randomUUID()};

  endDate = new Date();
  startDate = DateUtils.addDays(endDate, -1);

  populateDB();
}
 
開發者ID:YagelNasManit,項目名稱:environment.monitor,代碼行數:14,代碼來源:AggregatedStatusDAOTest.java

示例2: testResourceMonthDetailDAOGetAggregatedStatusesMonthIterate

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Test
public void testResourceMonthDetailDAOGetAggregatedStatusesMonthIterate() throws Exception {
  String environmentName = this.getClass().getName() + UUID.randomUUID();

  final Date endDate = new Date();
  final Date startDate = DateUtils.addDays(endDate, -35);

  final Resource resource = rndResource();

  List<ResourceStatus> statusesOnline = generateN(500, () -> rndResStatus(resource, Status.Online, rndDate(startDate, endDate)));
  List<ResourceStatus> statusesUnknown = generateN(500, () -> rndResStatus(resource, Status.Unavailable, rndDate(startDate, endDate)));
  List<ResourceStatus> statusesUnavailable = generateN(500, () -> rndResStatus(resource, Status.Unknown, rndDate(startDate, endDate)));

  monthDetailDAO.insert(environmentName, statusesOnline);
  monthDetailDAO.insert(environmentName, statusesUnavailable);
  monthDetailDAO.insert(environmentName, statusesUnknown);

  List<AggregatedResourceStatus> statusList = aggregatedStatusDAO.getAggregatedStatuses(environmentName, startDate, endDate);

  Assert.assertEquals(statusList.stream().mapToLong(AggregatedResourceStatus::getCount).sum(), 1500);
  Assert.assertEquals(statusList.size(), 1);
  Assert.assertEquals(statusList.get(0).getCount(), 1500);
  Assert.assertEquals(statusList.get(0).getResourceStatuses().size(), 3);
  Assert.assertEquals(statusList.get(0).getResourceStatuses().get(0).getCount(), 500);
  Assert.assertEquals(statusList.get(0).getResourceStatuses().get(1).getCount(), 500);
  Assert.assertEquals(statusList.get(0).getResourceStatuses().get(2).getCount(), 500);


}
 
開發者ID:YagelNasManit,項目名稱:environment.monitor,代碼行數:30,代碼來源:AggregatedStatusDAOTest.java

示例3: addTimeDelta

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
private Date addTimeDelta(final Date date, final int days, final int hours, final int minutes) {
    return DateUtils.addDays(
            DateUtils.addMinutes(
                    DateUtils.addHours(
                            date,
                            hours
                    ),
                    minutes
            ),
            days
    );
}
 
開發者ID:gandreadis,項目名稱:vu-timetable,代碼行數:13,代碼來源:Parser.java

示例4: parseRangeAndUpdate

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
protected void parseRangeAndUpdate(Date startDate, Date endDate, String directory,
    PostgreStorage storage, String market)
    throws IOException, ParseException {
  while (startDate.before(endDate) || startDate.equals(endDate)) {
    parseAndUpdate(startDate, directory, storage, market);
    startDate = DateUtils.addDays(startDate, 1);
  }
}
 
開發者ID:longkerdandy,項目名稱:qfii-tracker,代碼行數:9,代碼來源:ConnectParser.java

示例5: downloadRange

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * Download pages from url with the specific date range
 *
 * @param directory Directory
 * @param startDate Start Date (include)
 * @param endDate End Date (include)
 */
protected void downloadRange(String directory, Date startDate, Date endDate, String url)
    throws IOException {
  while (startDate.before(endDate) || startDate.equals(endDate)) {
    download(directory, startDate, url);
    startDate = DateUtils.addDays(startDate, 1);
  }
}
 
開發者ID:longkerdandy,項目名稱:qfii-tracker,代碼行數:15,代碼來源:Spider.java

示例6: process

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Override
public Object process(AnnotationInfo ctx, Object value) throws Exception {
    if (!ctx.isAnnotationPresent(Future.class)) {
        return value;
    }
    return DateUtils.addDays(new Date(), 2);
}
 
開發者ID:randomito,項目名稱:randomito-all,代碼行數:8,代碼來源:FutureAnnotationPostProcessor.java

示例7: process

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Override
public Object process(AnnotationInfo ctx, Object value) throws Exception {
    if (!ctx.isAnnotationPresent(Past.class)) {
        return value;
    }
    return DateUtils.addDays(new Date(), -2);
}
 
開發者ID:randomito,項目名稱:randomito-all,代碼行數:8,代碼來源:PastAnnotationPostProcessor.java

示例8: validate

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Override
public String validate(String driverClassName, String url, String username, String password,
    HttpRequest request, HashMap<String, String> params) {
    //sd=20.01.2009&ed=28.01.2009
    // проверка на корректность введенных параметров
    QLog.l().logger().trace("Принятые параметры \"" + params.toString() + "\".");
    if (params.size() == 2) {
        Date sd;
        Date fd;
        Date fd1;
        try {
            sd = Uses.FORMAT_DD_MM_YYYY.parse(params.get("sd"));
            fd = Uses.FORMAT_DD_MM_YYYY.parse(params.get("ed"));
            fd1 = DateUtils.addDays(Uses.FORMAT_DD_MM_YYYY.parse(params.get("ed")), 1);
        } catch (ParseException ex) {
            return "<br>Ошибка ввода параметров! Не все параметры введены корректно(дд.мм.гггг).";
        }
        if (!sd.after(fd)) {
            paramMap.put("sd", sd);
            paramMap.put("ed", fd);
            paramMap.put("ed1", fd1);
        } else {
            return "<br>Ошибка ввода параметров! Дата начала больше даты завершения.";
        }

    } else {
        return "<br>Ошибка ввода параметров!";
    }
    return null;// все нормально
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:31,代碼來源:RatioServices.java

示例9: validate

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Override
public String validate(String driverClassName, String url, String username, String password,
    HttpRequest request, HashMap<String, String> params) {
    //sd=20.01.2009&ed=28.01.2009
    // проверка на корректность введенных параметров
    QLog.l().logger().trace("Принятые параметры \"" + params.toString() + "\".");
    if (params.size() == 2) {
        Date sd, fd, fd1;
        try {
            sd = Uses.FORMAT_DD_MM_YYYY.parse(params.get("sd"));
            fd = Uses.FORMAT_DD_MM_YYYY.parse(params.get("ed"));
            fd1 = DateUtils.addDays(Uses.FORMAT_DD_MM_YYYY.parse(params.get("ed")), 1);
        } catch (ParseException ex) {
            return "<br>Ошибка ввода параметров! Не все параметры введены корректно(дд.мм.гггг).";
        }
        if (!sd.after(fd)) {
            paramMap.put("sd", sd);
            paramMap.put("ed", fd);
            paramMap.put("ed1", fd1);
        } else {
            return "<br>Ошибка ввода параметров! Дата начала больше даты завершения.";
        }

    } else {
        return "<br>Ошибка ввода параметров!";
    }
    return null;// все нормально
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:29,代碼來源:StatisticUsers.java

示例10: validate

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Override
public String validate(String driverClassName, String url, String username, String password,
    HttpRequest request, HashMap<String, String> params) {
    // проверка на корректность введенных параметров
    QLog.l().logger().trace("Принятые параметры \"" + params.toString() + "\".");
    if (params.size() == 2) {
        Date sd;
        Date fd;
        Date fd1;
        try {
            sd = Uses.FORMAT_DD_MM_YYYY.parse(params.get("sd"));
            fd = Uses.FORMAT_DD_MM_YYYY.parse(params.get("ed"));
            fd1 = DateUtils.addDays(Uses.FORMAT_DD_MM_YYYY.parse(params.get("ed")), 1);
        } catch (ParseException ex) {
            return "<br>Ошибка ввода параметров! Не все параметры введены корректно(дд.мм.гггг).";
        }
        if (!sd.after(fd)) {
            paramMap.put("sd", sd);
            paramMap.put("ed", fd);
            paramMap.put("ed1", fd1);
        } else {
            return "<br>Ошибка ввода параметров! Дата начала больше даты завершения.";
        }

    } else {
        return "<br>Ошибка ввода параметров!";
    }
    return null;// все нормально
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:30,代碼來源:ResponsesDateReport.java

示例11: getYesterday

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
public static Date getYesterday(Date currentDate) {
  return DateUtils.addDays(currentDate, -1);
}
 
開發者ID:YagelNasManit,項目名稱:environment.monitor,代碼行數:4,代碼來源:DataUtils.java

示例12: addDays

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 加一天
 */
public static Date addDays(@NotNull final Date date, final int amount) {
	return DateUtils.addDays(date, amount);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:DateUtil.java

示例13: subDays

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 減一天
 */
public static Date subDays(@NotNull final Date date, int amount) {
	return DateUtils.addDays(date, -amount);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:DateUtil.java

示例14: addDay

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * 一個日期對象+ n天
 *
 * @param date 日期
 * @param day  天數
 * @return
 */
public static Date addDay(Date date, int day) {
    return DateUtils.addDays(date, day);
}
 
開發者ID:peng9627,項目名稱:hall,代碼行數:11,代碼來源:CoreDateUtils.java

示例15: addDays

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * @param date   當前時間
 * @param amount 需要增加天數
 * @return 增加後時間
 * @description 增加天
 */
public static Date addDays(Date date, int amount) {
    return DateUtils.addDays(date, amount);
}
 
開發者ID:tong12580,項目名稱:OutsourcedProject,代碼行數:10,代碼來源:DateUtil.java


注:本文中的org.apache.commons.lang3.time.DateUtils.addDays方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。