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


Java DateUtils.addMonths方法代碼示例

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


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

示例1: genArticles

import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
 * Generates some dummy articles with the specified context.
 * 
 * @param context
 *            the specified context
 * @param request
 *            the specified request
 * @param response
 *            the specified response
 * @throws IOException
 *             io exception
 */
@RequestMapping(value = "/dev/articles/gen/*", method = RequestMethod.GET)
public void genArticles(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
	if (RuntimeMode.DEVELOPMENT != Latkes.getRuntimeMode()) {
		logger.warn("Article generation just for development mode, " + "current runtime mode is [{}]",
				Latkes.getRuntimeMode());
		response.sendRedirect(Latkes.getServePath());
		return;
	}

	Stopwatchs.start("Gen Articles");

	final String requestURI = request.getRequestURI();
	final int num = Integer
			.valueOf(requestURI.substring((Latkes.getContextPath() + "/dev/articles/gen/").length()));

	try {
		final JSONObject admin = userQueryService.getAdmin();
		final String authorEmail = admin.optString(User.USER_EMAIL);

		for (int i = 0; i < num; i++) {
			final JSONObject article = new JSONObject();

			article.put(Article.ARTICLE_TITLE, "article title" + i);
			article.put(Article.ARTICLE_ABSTRACT, "article" + i + " abstract");
			final int deviationTag = 3;

			article.put(Article.ARTICLE_TAGS_REF, "taga,tagb,tag" + i % deviationTag);
			article.put(Article.ARTICLE_AUTHOR_EMAIL, authorEmail);
			article.put(Article.ARTICLE_COMMENT_COUNT, 0);
			article.put(Article.ARTICLE_VIEW_COUNT, 0);
			article.put(Article.ARTICLE_CONTENT, "article content");
			article.put(Article.ARTICLE_PERMALINK, "article" + i + " permalink");
			article.put(Article.ARTICLE_HAD_BEEN_PUBLISHED, true);
			article.put(Article.ARTICLE_IS_PUBLISHED, true);
			article.put(Article.ARTICLE_PUT_TOP, false);

			final int deviationBase = 5;
			final int deviationDay = -(Integer.valueOf(String.valueOf(i).substring(0, 1)) % deviationBase);

			final Date date = DateUtils.addMonths(new Date(), deviationDay);

			article.put(Article.ARTICLE_CREATE_DATE, date);
			article.put(Article.ARTICLE_UPDATE_DATE, date);

			article.put(Article.ARTICLE_RANDOM_DOUBLE, Math.random());
			article.put(Article.ARTICLE_COMMENTABLE, true);
			article.put(Article.ARTICLE_VIEW_PWD, "");
			article.put(Article.ARTICLE_SIGN_ID, "1");

			articleMgmtService.addArticle(new JSONObject().put(Article.ARTICLE, article));
		}

	} catch (final Exception e) {
		logger.error(e.getMessage(), e);
	}

	Stopwatchs.end();

	response.sendRedirect(Latkes.getServePath());
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:73,代碼來源:ArticleGenerator.java

示例2: addMonths

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

示例3: subMonths

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

示例4: addMonths

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


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